baldiajaib Posted May 13, 2011 Share Posted May 13, 2011 I have a problem here..My page is a set of question (survey). here there are 9 sets of questions which are all RADIO BUTTONS. i used JavaScript to validate to make sure that EVERY BUTTON @ QUESTIONS IS CHECKED. The problem is the validation does not run even though I left one @ several question unchecked <?php ob_start(); session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> [bad html removed] This webpage is created by Aman bin Awaludin © 2011. All Rights Reserved --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> [bad html removed] .style1 {font-family: arial, verdana, sans-serif; font-size:13px;} .style3 {font-family: arial, verdana, sans-serif; font-weight: bold; } .style5 { font-family: arial, verdana, sans-serif; font-style: italic; font-size: 12px; } .style6 { color: #FF0000; font-weight: bold; } .style7 {font-size: 12px; font-family: arial, verdana, sans-serif;} --> </style> <script type="text/javascript"> [bad html removed] function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <script type="text/javascript" language="javascript"> [bad html removed] function validateprojek ( ) { var isValid = true; if (( !form.q1[0].checked) && ( !form.q1[1].checked) && ( !form.q1[2].checked) && ( !form.q1[3].checked) && ( !form.q1[4].checked)) { alert ( "Soalan 1 Tidak Dijawab!" ); isValid = false; } else if (( form.q2[0].checked) && ( form.q2[1].checked) && ( form.q2[2].checked) && ( form.q2[3].checked) && ( form.q2[4].checked)) { alert ( "Soalan 2 Tidak Dijawab!" ); isValid = false; } else if (( form.q3[0].checked) && ( form.q3[1].checked) && ( form.q3[2].checked) && ( form.q3[3].checked) && ( form.q3[4].checked)) { alert ( "Soalan 3 Tidak Dijawab!" ); isValid = false; } else if (( form.q4[0].checked) && ( form.q4[1].checked) && ( form.q4[2].checked) && ( form.q4[3].checked) && ( form.q4[4].checked)) { alert ( "Soalan 4 Tidak Dijawab!" ); isValid = false; } else if (( form.q5[0].checked) && ( form.q5[1].checked) && ( form.q5[2].checked) && ( form.q5[3].checked) && ( form.q5[4].checked)) { alert ( "Soalan 5 Tidak Dijawab!" ); isValid = false; } else if (( form.q6[0].checked) && ( form.q6[1].checked) && ( form.q6[2].checked) && ( form.q6[3].checked) && ( form.q6[4].checked)) { alert ( "Soalan 6 Tidak Dijawab!" ); isValid = false; } else if (( form.q7[0].checked) && ( form.q7[1].checked) && ( form.q7[2].checked) && ( form.q7[3].checked) && ( form.q7[4].checked)) { alert ( "Soalan 7 Tidak Dijawab!" ); isValid = false; } else if (( form.q8[0].checked) && ( form.q8[1].checked) && ( form.q8[2].checked) && ( form.q8[3].checked) && ( form.q8[4].checked)) { alert ( "Soalan 8 Tidak Dijawab!" ); isValid = false } else if (( form.q9[0].checked) && ( form.q9[1].checked) && ( form.q9[2].checked) && ( form.q9[3].checked) && ( form.q9[4].checked)) { alert ( "Soalan 9 Tidak Dijawab!" ); isValid = false } return isValid; } //--> </script> </head> <body onload="MM_preloadImages('image/next2.png')"> <?php if (isset ($_SESSION['resultX1'])) { echo '<p align="center" class="style7">Penilaian Kategori Projek bagi Projek ini telah dibuat. Soalan dan Jawapan Penilaian akan dipaparkan sebentar lagi..</p>'; header("Refresh: 3; url=\"jawapanprojek.php\""); exit(); } if (!isset ($_SESSION['namaProjek'])){ echo '<p align="center" class="style7">Anda belum lagi membuat pilihan memulakan Penilaian Baru. Sila pastikan borang di sebelah di isikan dahulu..</p>'; //header("Refresh: 3; url=\"index.php\""); exit(); } if (!isset($_SESSION["manager"])) { header("location: Login.php"); exit(); } //Be sure to check that this manager SESSION value is in fact in the database $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); // filter everything but numbers and letters $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); // filter everything but numbers and letters //Run mySQL query to be sure that this person is an admin and that their password session var equals the database information //Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $sql = mysql_query("SELECT * FROM company WHERE companyId='$managerID' AND username='$manager' AND password='$password' LIMIT 1"); // query the person // ------- MAKE SURE PERSON EXISTS IN DATABASE --------- $existCount = mysql_num_rows($sql); // count the row nums if ($existCount == 0) { // evaluate the count echo "Your login session data is not on record in the database. Go to <a href='Login.php'>Login Page</a>"; exit(); } $namaprojek2 = $_SESSION['namaProjek']; $id3 = $_SESSION['id']; $id4 = $_SESSION['idprojek']; $sql3 = mysql_query("SELECT * FROM project WHERE projectname = '$namaprojek2' AND companyId = '$id3' AND projectId = '$id4'"); $displayoutput2 = mysql_num_rows($sql3); if ($displayoutput2 > 0) { while($row2 = mysql_fetch_array($sql3)){ $a1 = $row2['q1']; $a2 = $row2['q2']; $a3 = $row2['q3']; $a4 = $row2['q4']; $a5 = $row2['q5']; $a6 = $row2['q6']; $a7 = $row2['q7']; $a8 = $row2['q8']; $a9 = $row2['q9']; $a10 = $row2['q10']; $a11 = $row2['q11']; $a12 = $row2['q12']; $a13 = $row2['q13']; $a14 = $row2['q14']; $a15 = $row2['q15']; $a16 = $row2['q16']; } } ob_flush(); ?> [bad html removed]IFRAME SCROLLING USING JAVASCRIPT & ARROW IMAGE--> <div id="staticbuttons" style="position:absolute;"> <a href="javascript:" onMouseOver="myspeed=-thespeed" onMouseOut="myspeed=0"><img src="image/arrowup.png" border="0"></a><br> <a href="javascript:" onMouseOver="myspeed=thespeed" onMouseOut="myspeed=0"><img src="image/arrowdown.png" border="0"></a></div> <script> var Hoffset=50 //Enter buttons' offset from right edge of window (adjust depending on images width) var Voffset=80 //Enter buttons' offset from bottom edge of window (adjust depending on images height) var thespeed=4 //Enter scroll speed in integer (Advised: 1-3) var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1 var myspeed=0 var ieHoffset_extra=document.all? 15 : 0 var cross_obj=document.all? document.all.staticbuttons : document.getElementById? document.getElementById("staticbuttons") : document.staticbuttons function iecompattest(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function positionit(){ var dsocleft=document.all? iecompattest().scrollLeft : pageXOffset var dsoctop=document.all? iecompattest().scrollTop : pageYOffset var window_width=ieNOTopera? iecompattest().clientWidth+ieHoffset_extra : window.innerWidth+ieHoffset_extra var window_height=ieNOTopera? iecompattest().clientHeight : window.innerHeight if (document.all||document.getElementById){ cross_obj.style.left=parseInt(dsocleft)+parseInt(window_width)-Hoffset+"px" cross_obj.style.top=dsoctop+parseInt(window_height)-Voffset+"px" } else if (document.layers){ cross_obj.left=dsocleft+window_width-Hoffset cross_obj.top=dsoctop+window_height-Voffset } } function scrollwindow(){ window.scrollBy(0,myspeed) } function initializeIT(){ positionit() if (myspeed!=0){ scrollwindow() } } if (document.all||document.getElementById||document.layers) setInterval("initializeIT()",20) /** ALLOWS MOUSEWHEEL SCROLLING * It must react to delta being more/less than zero. */ function handle(delta) { var d=delta*-10; window.scrollBy(0,d); } /** Event handler for mouse wheel event. */ function wheel(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } /** If delta is nonzero, handle it. * Basically, delta is now positive if wheel was scrolled up, * and negative, if wheel was scrolled down. */ if (delta) handle(delta); /** Prevent default actions caused by mouse wheel. * That might be ugly, but we handle scrolls somehow * anyway, so don't bother here.. */ if (event.preventDefault) event.preventDefault(); event.returnValue = false; } /** Initialization code. * If you use your own event management code, change it as required. */ if (window.addEventListener) /** DOMMouseScroll is for mozilla. */ window.addEventListener('DOMMouseScroll', wheel, false); /** IE/Opera. */ window.onmousewheel = document.onmousewheel = wheel; </script> <div align="center"><img src="image/4.png" width="800" height="94" /></div> </br></br> <div align="center"> <p class="style3">Kerapian Takrifan: Objektif dan Justifikasi Projek</p> <p align="center"><span class="style7">SKALA</span><span class="style5">: <span class="style6">4</span> = Cemerlang; <strong class="style6">3</strong> = Baik; <strong class="style6">2</strong> = Purata; <strong class="style6">1</strong> = Bawah Purata; <strong class="style6">0</strong> = Tidak Boleh Diterima</span></p> <form id="projek" name="projek" method="post" action="projek2.php" > <table width="694" border="0"> <tr bgcolor="#666666"> <td width="61"><div align="center" class="style3">Bil.</div></td> <td width="439"><div align="center" class="style3">Pengukur</div></td> <td width="180"><div align="center" class="style3">Skala</div></td> </tr> <tr bgcolor="#E7F3F1"> <td><div align="center" class="style1">1</div></td> <td><p class="style1">Objektif projek spesifik serta jelas (iaitu objektif projek menyatakan dengan tepat dan jelas apa yang hendak dicapai).</p></td> <td class="style1"><input type="radio" name="q1" id="q1" value="4"> 4 <input type="radio" name="q1" id="q1" value="3"> 3 <input type="radio" name="q1" id="q1" value="2"> 2 <input type="radio" name="q1" id="q1" value="1"> 1 <input type="radio" name="q1" id="q1" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">2</div></td> <td><p class="style1">Objektif projek boleh diukur (iaitu objektif projek menyatakan ukuran yang hendak dicapai).</p></td> <td class="style1"><input type="radio" name="q2" id="q2" value="4"> 4 <input type="radio" name="q2" id="q2" value="3"> 3 <input type="radio" name="q2" id="q2" value="2"> 2 <input type="radio" name="q2" id="q2" value="1"> 1 <input type="radio" name="q2" id="q2" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">3</div></td> <td class="style1"><p>Objektif projek boleh dicapai dalam masa yang ditetapkan.</p></td> <td class="style1"><input type="radio" name="q3" id="q3" value="4"> 4 <input type="radio" name="q3" id="q3" value="3"> 3 <input type="radio" name="q3" id="q3" value="2"> 2 <input type="radio" name="q3" id="q3" value="1"> 1 <input type="radio" name="q3" id="q3" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">4</div></td> <td class="style1"><p>Objektif projek realistik.</p></td> <td class="style1"><input type="radio" name="q4" id="q4" value="4"> 4 <input type="radio" name="q4" id="q4" value="3"> 3 <input type="radio" name="q4" id="q4" value="2"> 2 <input type="radio" name="q4" id="q4" value="1"> 1 <input type="radio" name="q4" id="q4" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">5</div></td> <td class="style1"><p>Objektif projek dipersetujui oleh <em>stakeholders </em>utama<em>.</em></p></td> <td class="style1"><input type="radio" name="q5" id="q5" value="4"> 4 <input type="radio" name="q5" id="q5" value="3"> 3 <input type="radio" name="q5" id="q5" value="2"> 2 <input type="radio" name="q5" id="q5" value="1"> 1 <input type="radio" name="q5" id="q5" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">6</div></td> <td class="style1"><p>Justifikasi menumpu kepada matlamat organisasi yang hendak dicapai.</p></td> <td class="style1"><input type="radio" name="q6" id="q6" value="4">4 <input type="radio" name="q6" id="q6" value="3"> 3 <input type="radio" name="q6" id="q6" value="2"> 2 <input type="radio" name="q6" id="q6" value="1"> 1 <input type="radio" name="q6" id="q6" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">7</div></td> <td class="style1"><p>Justifikasi menyatakan kepentingan atau faedah yang akan diperoleh dengan terlaksananya projek </p></td> <td class="style1"><input type="radio" name="q7" id="q7" value="4"> 4 <input type="radio" name="q7" id="q7" value="3"> 3 <input type="radio" name="q7" id="q7" value="2"> 2 <input type="radio" name="q7" id="q7" value="1"> 1 <input type="radio" name="q7" id="q7" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">8</div></td> <td class="style1"><p>Justifikasi menyatakan peningkatan kemahiran kakitangan dengan terlaksananya projek. </p></td> <td class="style1"><input type="radio" name="q8" id="q8" value="4"> 4 <input type="radio" name="q8" id="q8" value="3"> 3 <input type="radio" name="q8" id="q8" value="2"> 2 <input type="radio" name="q8" id="q8" value="1"> 1 <input type="radio" name="q8" id="q8" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">9</div></td> <td class="style1"><p>Kesemua kerja yang terangkum dalam projek ditakrif dengan jelas.</p></td> <td class="style1"><input type="radio" name="q9" id="q9" value="4"> 4 <input type="radio" name="q9" id="q9" value="3"> 3 <input type="radio" name="q9" id="q9" value="2"> 2 <input type="radio" name="q9" id="q9" value="1"> 1 <input type="radio" name="q9" id="q9" value="0"> 0</td> </tr> </table> </br></br> <input name="submit" type="submit" value="Teruskan" onclick="javascript:return validateprojek();"/> </form> </body> </html> Googled everything, tried several tutorials but no good..thanks in advance guys Quote Link to comment https://forums.phpfreaks.com/topic/236334-radio-button-validation-not-running/ Share on other sites More sharing options...
baldiajaib Posted May 13, 2011 Author Share Posted May 13, 2011 i did some corrections, but still not working <?php ob_start(); session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> [bad html removed] This webpage is created by Aman bin Awaludin © 2011. All Rights Reserved --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> [bad html removed] .style1 {font-family: arial, verdana, sans-serif; font-size:13px;} .style3 {font-family: arial, verdana, sans-serif; font-weight: bold; } .style5 { font-family: arial, verdana, sans-serif; font-style: italic; font-size: 12px; } .style6 { color: #FF0000; font-weight: bold; } .style7 {font-size: 12px; font-family: arial, verdana, sans-serif;} --> </style> <script type="text/javascript"> [bad html removed] function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> <script type="text/javascript" language="javascript"> [bad html removed] function validateprojek ( ) { var isValid = true; if (( !form.q1[0].checked) && ( !form.q1[1].checked) && ( !form.q1[2].checked) && ( !form.q1[3].checked) && ( !form.q1[4].checked)) { alert ( "Soalan 1 Tidak Dijawab!" ); isValid = false; } else if (( !form.q2[0].checked) && ( !form.q2[1].checked) && ( !form.q2[2].checked) && ( !form.q2[3].checked) && ( !form.q2[4].checked)) { alert ( "Soalan 2 Tidak Dijawab!" ); isValid = false; } else if (( !form.q3[0].checked) && ( !form.q3[1].checked) && ( !form.q3[2].checked) && ( !form.q3[3].checked) && ( !form.q3[4].checked)) { alert ( "Soalan 3 Tidak Dijawab!" ); isValid = false; } else if (( !form.q4[0].checked) && ( !form.q4[1].checked) && ( !form.q4[2].checked) && ( !form.q4[3].checked) && ( !form.q4[4].checked)) { alert ( "Soalan 4 Tidak Dijawab!" ); isValid = false; } else if (( !form.q5[0].checked) && ( !form.q5[1].checked) && ( !form.q5[2].checked) && ( !form.q5[3].checked) && ( !form.q5[4].checked)) { alert ( "Soalan 5 Tidak Dijawab!" ); isValid = false; } else if (( !form.q6[0].checked) && ( !form.q6[1].checked) && ( !form.q6[2].checked) && ( !form.q6[3].checked) && ( !form.q6[4].checked)) { alert ( "Soalan 6 Tidak Dijawab!" ); isValid = false; } else if (( !form.q7[0].checked) && ( !form.q7[1].checked) && ( !form.q7[2].checked) && ( !form.q7[3].checked) && ( !form.q7[4].checked)) { alert ( "Soalan 7 Tidak Dijawab!" ); isValid = false; } else if (( !form.q8[0].checked) && ( !form.q8[1].checked) && ( !form.q8[2].checked) && ( !form.q8[3].checked) && ( !form.q8[4].checked)) { alert ( "Soalan 8 Tidak Dijawab!" ); isValid = false } else if (( !form.q9[0].checked) && ( !form.q9[1].checked) && ( !form.q9[2].checked) && ( !form.q9[3].checked) && ( !form.q9[4].checked)) { alert ( "Soalan 9 Tidak Dijawab!" ); isValid = false } return isValid; } //--> </script> </head> <body onload="MM_preloadImages('image/next2.png')"> <?php if (isset ($_SESSION['resultX1'])) { echo '<p align="center" class="style7">Penilaian Kategori Projek bagi Projek ini telah dibuat. Soalan dan Jawapan Penilaian akan dipaparkan sebentar lagi..</p>'; header("Refresh: 3; url=\"jawapanprojek.php\""); exit(); } if (!isset ($_SESSION['namaProjek'])){ echo '<p align="center" class="style7">Anda belum lagi membuat pilihan memulakan Penilaian Baru. Sila pastikan borang di sebelah di isikan dahulu..</p>'; //header("Refresh: 3; url=\"index.php\""); exit(); } if (!isset($_SESSION["manager"])) { header("location: Login.php"); exit(); } //Be sure to check that this manager SESSION value is in fact in the database $managerID = preg_replace('#[^0-9]#i', '', $_SESSION["id"]); // filter everything but numbers and letters $manager = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["manager"]); // filter everything but numbers and letters $password = preg_replace('#[^A-Za-z0-9]#i', '', $_SESSION["password"]); // filter everything but numbers and letters //Run mySQL query to be sure that this person is an admin and that their password session var equals the database information //Connect to the MySQL database include "storescripts/connect_to_mysql.php"; $sql = mysql_query("SELECT * FROM company WHERE companyId='$managerID' AND username='$manager' AND password='$password' LIMIT 1"); // query the person // ------- MAKE SURE PERSON EXISTS IN DATABASE --------- $existCount = mysql_num_rows($sql); // count the row nums if ($existCount == 0) { // evaluate the count echo "Your login session data is not on record in the database. Go to <a href='Login.php'>Login Page</a>"; exit(); } $namaprojek2 = $_SESSION['namaProjek']; $id3 = $_SESSION['id']; $id4 = $_SESSION['idprojek']; $sql3 = mysql_query("SELECT * FROM project WHERE projectname = '$namaprojek2' AND companyId = '$id3' AND projectId = '$id4'"); $displayoutput2 = mysql_num_rows($sql3); if ($displayoutput2 > 0) { while($row2 = mysql_fetch_array($sql3)){ $a1 = $row2['q1']; $a2 = $row2['q2']; $a3 = $row2['q3']; $a4 = $row2['q4']; $a5 = $row2['q5']; $a6 = $row2['q6']; $a7 = $row2['q7']; $a8 = $row2['q8']; $a9 = $row2['q9']; $a10 = $row2['q10']; $a11 = $row2['q11']; $a12 = $row2['q12']; $a13 = $row2['q13']; $a14 = $row2['q14']; $a15 = $row2['q15']; $a16 = $row2['q16']; } } ob_flush(); ?> [bad html removed]IFRAME SCROLLING USING JAVASCRIPT & ARROW IMAGE--> <div id="staticbuttons" style="position:absolute;"> <a href="javascript:" onMouseOver="myspeed=-thespeed" onMouseOut="myspeed=0"><img src="image/arrowup.png" border="0"></a><br> <a href="javascript:" onMouseOver="myspeed=thespeed" onMouseOut="myspeed=0"><img src="image/arrowdown.png" border="0"></a></div> <script> var Hoffset=50 //Enter buttons' offset from right edge of window (adjust depending on images width) var Voffset=80 //Enter buttons' offset from bottom edge of window (adjust depending on images height) var thespeed=4 //Enter scroll speed in integer (Advised: 1-3) var ieNOTopera=document.all&&navigator.userAgent.indexOf("Opera")==-1 var myspeed=0 var ieHoffset_extra=document.all? 15 : 0 var cross_obj=document.all? document.all.staticbuttons : document.getElementById? document.getElementById("staticbuttons") : document.staticbuttons function iecompattest(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function positionit(){ var dsocleft=document.all? iecompattest().scrollLeft : pageXOffset var dsoctop=document.all? iecompattest().scrollTop : pageYOffset var window_width=ieNOTopera? iecompattest().clientWidth+ieHoffset_extra : window.innerWidth+ieHoffset_extra var window_height=ieNOTopera? iecompattest().clientHeight : window.innerHeight if (document.all||document.getElementById){ cross_obj.style.left=parseInt(dsocleft)+parseInt(window_width)-Hoffset+"px" cross_obj.style.top=dsoctop+parseInt(window_height)-Voffset+"px" } else if (document.layers){ cross_obj.left=dsocleft+window_width-Hoffset cross_obj.top=dsoctop+window_height-Voffset } } function scrollwindow(){ window.scrollBy(0,myspeed) } function initializeIT(){ positionit() if (myspeed!=0){ scrollwindow() } } if (document.all||document.getElementById||document.layers) setInterval("initializeIT()",20) /** ALLOWS MOUSEWHEEL SCROLLING * It must react to delta being more/less than zero. */ function handle(delta) { var d=delta*-10; window.scrollBy(0,d); } /** Event handler for mouse wheel event. */ function wheel(event){ var delta = 0; if (!event) /* For IE. */ event = window.event; if (event.wheelDelta) { /* IE/Opera. */ delta = event.wheelDelta/120; /** In Opera 9, delta differs in sign as compared to IE. */ if (window.opera) delta = -delta; } else if (event.detail) { /** Mozilla case. */ /** In Mozilla, sign of delta is different than in IE. * Also, delta is multiple of 3. */ delta = -event.detail/3; } /** If delta is nonzero, handle it. * Basically, delta is now positive if wheel was scrolled up, * and negative, if wheel was scrolled down. */ if (delta) handle(delta); /** Prevent default actions caused by mouse wheel. * That might be ugly, but we handle scrolls somehow * anyway, so don't bother here.. */ if (event.preventDefault) event.preventDefault(); event.returnValue = false; } /** Initialization code. * If you use your own event management code, change it as required. */ if (window.addEventListener) /** DOMMouseScroll is for mozilla. */ window.addEventListener('DOMMouseScroll', wheel, false); /** IE/Opera. */ window.onmousewheel = document.onmousewheel = wheel; </script> <div align="center"><img src="image/4.png" width="800" height="94" /></div> </br></br> <div align="center"> <p class="style3">Kerapian Takrifan: Objektif dan Justifikasi Projek</p> <p align="center"><span class="style7">SKALA</span><span class="style5">: <span class="style6">4</span> = Cemerlang; <strong class="style6">3</strong> = Baik; <strong class="style6">2</strong> = Purata; <strong class="style6">1</strong> = Bawah Purata; <strong class="style6">0</strong> = Tidak Boleh Diterima</span></p> <form id="projek" name="projek" method="post" action="projek2.php" > <table width="694" border="0"> <tr bgcolor="#666666"> <td width="61"><div align="center" class="style3">Bil.</div></td> <td width="439"><div align="center" class="style3">Pengukur</div></td> <td width="180"><div align="center" class="style3">Skala</div></td> </tr> <tr bgcolor="#E7F3F1"> <td><div align="center" class="style1">1</div></td> <td><p class="style1">Objektif projek spesifik serta jelas (iaitu objektif projek menyatakan dengan tepat dan jelas apa yang hendak dicapai).</p></td> <td class="style1"><input type="radio" name="q1" id="q1" value="4"> 4 <input type="radio" name="q1" id="q1" value="3"> 3 <input type="radio" name="q1" id="q1" value="2"> 2 <input type="radio" name="q1" id="q1" value="1"> 1 <input type="radio" name="q1" id="q1" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">2</div></td> <td><p class="style1">Objektif projek boleh diukur (iaitu objektif projek menyatakan ukuran yang hendak dicapai).</p></td> <td class="style1"><input type="radio" name="q2" id="q2" value="4"> 4 <input type="radio" name="q2" id="q2" value="3"> 3 <input type="radio" name="q2" id="q2" value="2"> 2 <input type="radio" name="q2" id="q2" value="1"> 1 <input type="radio" name="q2" id="q2" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">3</div></td> <td class="style1"><p>Objektif projek boleh dicapai dalam masa yang ditetapkan.</p></td> <td class="style1"><input type="radio" name="q3" id="q3" value="4"> 4 <input type="radio" name="q3" id="q3" value="3"> 3 <input type="radio" name="q3" id="q3" value="2"> 2 <input type="radio" name="q3" id="q3" value="1"> 1 <input type="radio" name="q3" id="q3" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">4</div></td> <td class="style1"><p>Objektif projek realistik.</p></td> <td class="style1"><input type="radio" name="q4" id="q4" value="4"> 4 <input type="radio" name="q4" id="q4" value="3"> 3 <input type="radio" name="q4" id="q4" value="2"> 2 <input type="radio" name="q4" id="q4" value="1"> 1 <input type="radio" name="q4" id="q4" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">5</div></td> <td class="style1"><p>Objektif projek dipersetujui oleh <em>stakeholders </em>utama<em>.</em></p></td> <td class="style1"><input type="radio" name="q5" id="q5" value="4"> 4 <input type="radio" name="q5" id="q5" value="3"> 3 <input type="radio" name="q5" id="q5" value="2"> 2 <input type="radio" name="q5" id="q5" value="1"> 1 <input type="radio" name="q5" id="q5" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">6</div></td> <td class="style1"><p>Justifikasi menumpu kepada matlamat organisasi yang hendak dicapai.</p></td> <td class="style1"><input type="radio" name="q6" id="q6" value="4">4 <input type="radio" name="q6" id="q6" value="3"> 3 <input type="radio" name="q6" id="q6" value="2"> 2 <input type="radio" name="q6" id="q6" value="1"> 1 <input type="radio" name="q6" id="q6" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">7</div></td> <td class="style1"><p>Justifikasi menyatakan kepentingan atau faedah yang akan diperoleh dengan terlaksananya projek </p></td> <td class="style1"><input type="radio" name="q7" id="q7" value="4"> 4 <input type="radio" name="q7" id="q7" value="3"> 3 <input type="radio" name="q7" id="q7" value="2"> 2 <input type="radio" name="q7" id="q7" value="1"> 1 <input type="radio" name="q7" id="q7" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">8</div></td> <td class="style1"><p>Justifikasi menyatakan peningkatan kemahiran kakitangan dengan terlaksananya projek. </p></td> <td class="style1"><input type="radio" name="q8" id="q8" value="4"> 4 <input type="radio" name="q8" id="q8" value="3"> 3 <input type="radio" name="q8" id="q8" value="2"> 2 <input type="radio" name="q8" id="q8" value="1"> 1 <input type="radio" name="q8" id="q8" value="0"> 0</td> </tr> <tr bgcolor="#E7F3F1"> <td class="style1"><div align="center">9</div></td> <td class="style1"><p>Kesemua kerja yang terangkum dalam projek ditakrif dengan jelas.</p></td> <td class="style1"><input type="radio" name="q9" id="q9" value="4"> 4 <input type="radio" name="q9" id="q9" value="3"> 3 <input type="radio" name="q9" id="q9" value="2"> 2 <input type="radio" name="q9" id="q9" value="1"> 1 <input type="radio" name="q9" id="q9" value="0"> 0</td> </tr> </table> </br></br> <input name="submit" type="submit" value="Teruskan" onclick="javascript:return validateprojek();"/> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/236334-radio-button-validation-not-running/#findComment-1215079 Share on other sites More sharing options...
Zane Posted May 14, 2011 Share Posted May 14, 2011 i used JavaScript to validate You should never validate with Javascript. Especially if this is an end-user application where the user can literally turn Javascript off. I suggest you redo your validation in PHP. Quote Link to comment https://forums.phpfreaks.com/topic/236334-radio-button-validation-not-running/#findComment-1215371 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.