r-it Posted February 14, 2007 Share Posted February 14, 2007 can someone help me, i hv a form whose action is self, i want 2 check a certain text box is not empty when i click the submit button and it must show me an alert box. the thing is it does this, but continues with the action after it shows me the alert box, so the form is submitted to the server regardless. How can i stop the form being submitted to the server if the text box is empty and make it focus there instead of submitting it. it should only submit when this condition is true. thanx Link to comment https://forums.phpfreaks.com/topic/38444-php-and-javascript/ Share on other sites More sharing options...
JasonLewis Posted February 14, 2007 Share Posted February 14, 2007 this is how to get that working, even though it isnt really a php question. <script language="javascript"> function check(){ errors = ""; count = 1; if(document.getElementById("name").value == ""){ errors += count+". You didn't enter a name.\n"; count++; } if(document.getElementById("msg").value == ""){ errors += count+". You didn't enter a message.\n"; count++; } if(errors != ""){ alert("We found the following errors:\n"+errors); return false; }else{ return true; } } </script> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST"> Name: <input type="text" name="name" id="name"><br> Message: <input type="text" name="msg" id="msg"><br> <input type="submit" name="submit" value="go" onclick="javascript: return check()"> </form> notice the return statements made. hope that works for you. Link to comment https://forums.phpfreaks.com/topic/38444-php-and-javascript/#findComment-184456 Share on other sites More sharing options...
r-it Posted February 14, 2007 Author Share Posted February 14, 2007 thanks a lot ProjectFear, so its the return that makes the difference. But now i have a problem with your script that i'm testing, it doesnt focus on the text box with the error, i have the script like this: <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <script language="javascript"> function check(){ errors = ""; count = 1; if(document.getElementById("name").value == ""){ errors += count+". You didn't enter a name.\n"; document.test.name.focus(); count++; } if(document.getElementById("msg").value == ""){ errors += count+". You didn't enter a message.\n"; document.test.msg.focus(); count++; } if(errors != ""){ alert("We found the following errors:\n"+errors); return false; }else{ return true; } } </script> </head> <body> <?php if(!$HTTP_POST_VARS) { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" name="test"> Name: <input type="text" name="name" id="name"><br> Message: <input type="text" name="msg" id="msg"><br> <input type="submit" name="submit" value="go" onclick="javascript: return check()"> </form> <?php } else { $name = $_POST['name']; $msg = $_POST['msg']; echo $name."<br>".$msg; } ?> </body> </html> oh, and another thing i want to ask, whats the difference between the onsubmit at the top and the onclick at the bottom? Link to comment https://forums.phpfreaks.com/topic/38444-php-and-javascript/#findComment-184471 Share on other sites More sharing options...
r-it Posted February 14, 2007 Author Share Posted February 14, 2007 this thing is just giving me problems, i don't know why its not reading the javascript: <?php session_start(); require("connex.php"); $conn = new dbConnector(); ?> <!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> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Add new retail product</title> <script language="javascript"> function check(){ errors = ""; count = 1; if(document.getElementById("name").value == ""){ errors += count+". You didn't enter a name.\n"; document.test.name.focus(); count++; } if(document.getElementById("msg").value == ""){ errors += count+". You didn't enter a message.\n"; document.test.msg.focus(); count++; } if(errors != ""){ alert("We found the following errors:\n"+errors); return false; }else{ return true; } } </script> </head> <body bgcolor="#00CCFF"> <?php if(isset($_SESSION['username'])) { if($HTTP_POST_VARS) { //CHECK TYPE OF SUBMIT if($_POST['submit'] == "Cancel") { //must 1st delete records from the temptable $delete = "DELETE * FROM temp_retail"; $rezzz = $conn->query($delete); header("Location: addRetail.php"); exit; } elseif($_POST['submit'] == "<<") { //get all the posted details if($_POST['action'] == "first") { $group = $_POST['sel_grp']; $rpname = $_POST['name']; } else { $group = $_POST[hdGrp]; $rpname = $_POST[hdRp]; } $bitem = $_POST[lst_baseitems]; $check = "SELECT * FROM temp_retail WHERE rpItem = '$bitem'"; $result = $conn->query($check); if($result) { if(mysql_num_rows($result) > 0) { $upd = "UPDATE temp_retail SET qty = qty + 1 WHERE rpItem = '$bitem'"; $res = $conn->query($upd); $status = "in result update"; } else { $qry = "INSERT INTO temp_retail (grpName, rpName, rpItem, qty) VALUES ('".$group."', '".$rpname."', '".$bitem."', '1')"; $res = $conn->query($qry); $status = "in result insert"; } } else { $qry = "INSERT INTO temp_retail (grpName, rpName, rpItem, qty) VALUES ('".$group."', '".$rpname."', '".$bitem."', '1')"; $res = $conn->query($qry); } include_once 'form.php'; $show = $form; //$show = $rpname; } elseif($_POST['submit'] == ">>") { //get all the posted details $group = $_POST['hdGrp']; $rpname = $_POST['hdRp']; $ritem = $_POST['lst_rpitems']; $check = "SELECT * FROM temp_retail WHERE rpItem = '$ritem'"; $result = $conn->query($check); if(mysql_num_rows($result) > 0) { while($dd = $conn->fetchArray($result)) { $qty = $dd['qty']; } if($qty == 1) { $delsql = "DELETE FROM temp_retail WHERE rpItem = '$ritem'"; $res = $conn->query($delsql); $sql = "SELECT * FROM temp_retail"; $rez = $conn->query($sql); if(mysql_num_rows($rez) <> 1) { header("Location: addRetail.php"); } } else { $upd = "UPDATE temp_retail SET qty = qty - 1 WHERE rpItem = '$ritem'"; $res = $conn->query($upd); } } include_once 'form.php'; $show = $form; } elseif($_POST['submit'] == "Save") { //get all posted details $grpname = $_POST['hdGrp']; $rpname = $_POST['hdRp']; $price = $_POST['txPrice']; $yearpf = $_POST['sel_yearPF']; $mnthpf = $_POST['sel_monthPF']; $daypf = $_POST['sel_dayPF']; $hrspf = $_POST['sel_hrsPF']; $minspf = $_POST['sel_minsPF']; $yearpt = $_POST['sel_year_pto']; $mnthpt = $_POST['sel_month_pto']; $daypt = $_POST['sel_day_pto']; $hrspt = $_POST['sel_hrs_pto']; $minspt = $_POST['sel_mins_pto']; $yearaf = $_POST['sel_yearAF']; $mnthaf = $_POST['sel_monthAF']; $dayaf = $_POST['sel_dayAF']; $hrsaf = $_POST['sel_hrsAF']; $minsaf = $_POST['sel_minsAF']; $yearat = $_POST['sel_year_ato']; $mnthat = $_POST['sel_month_ato']; $dayat = $_POST['sel_day_ato']; $hrsat = $_POST['sel_hrs_ato']; $minsat = $_POST['sel_mins_ato']; $seconds = "00"; require_once 'functions.php'; $mnthpf = theCase($mnthpf); $mnthpt = theCase($mnthpt); $mnthaf = theCase($mnthaf); $mnthat = theCase($mnthat); $date_pfrom = $yearpf."-".$mnthpf."-".$daypf." ".$hrspf.":".$minspf.":".$seconds; $date_pto = $yearpt."-".$mnthpt."-".$daypt." ".$hrspt.":".$minspt.":".$seconds; $date_afrom = $yearaf."-".$mnthaf."-".$dayaf." ".$hrsaf.":".$minsaf.":".$seconds; $date_ato = $yearat."-".$mnthat."-".$dayat." ".$hrsat.":".$minsat.":".$seconds; //$show = $grpname."<br>".$rpname."<br>".$price; $save1 = "SELECT grpName, rpName FROM temp_retail LIMIT 1"; $res = $conn->query($save1); while($recz = $conn->fetchArray($res)) { $grpname = $recz['grpName']; $rpname = $recz['rpName']; $save2 = "SELECT groupID FROM grouptbl WHERE groupDesc = '$grpname'"; $res2 = $conn->query($save2); while($recz2 = $conn->fetchArray($res2)) { $grid = $recz2['groupID']; } } $insert1 = "INSERT INTO rptbl (groupID, rpName, dtAvailFrom, dtAvailTo) VALUES ('".$grid."','".$rpname."','".$date_afrom."','".$date_ato."')"; $insert1_res = $conn->query($insert1); $rpid = mysql_insert_id(); $insert2 = "INSERT INTO rppricetbl (rpID, rpPrice, dtEffectiveFrom, dtEffectiveTo) VALUES ('".$rpid."','".$price."','".$date_pfrom."','".$date_pto."')"; $insert2_res = $conn->query($insert2); $save2 = "SELECT * FROM temp_retail"; $res3 = $conn->query($save2); while($recz3 = $conn->fetchArray($res3)) { $rpitem = $recz3['rpItem']; $qty = $recz3['qty']; $insert = "INSERT INTO rplinktbl (rpID, baseID, qty) VALUES ('".$rpid."','".$rpitem."','".$qty."')"; $insert_res = $conn->query($insert); } $delete = "DELETE * FROM temp_retail"; $rezzz = $conn->query($delete); header("Location: addRetail.php"); exit; } } else { //remove everything from temporary table $delete = "DELETE FROM temp_retail"; $rezzz = $conn->query($delete); //show clear form $show = "<form action=\"$_SERVER[php_SELF]\" method=\"post\" name=\"fmRetail\" > <table width=\"35%\"> <tr> <th align=\"left\">Group:</th> <td><select name=\"sel_grp\" size=\"1\">"; $qry1 = "SELECT * FROM grouptbl ORDER BY groupID"; $rez = $conn->query($qry1); while($rec = $conn->fetchArray($rez)) { $grname = $rec['groupDesc']; $show .= "<option value= \"$grname\">$grname</option>"; } $show .= "</select></td> </tr> <tr> <th align=\"left\">Retail product name:</th> <td><input type=\"text\" name=\"name\" id=\"rpname\" size=\"30\" /><input type=\"hidden\" name=\"action\" value=\"first\"></td> </tr> </table> <br /> <br /> <table width=\"70%\"> <tr> <th width=\"35%\" align=\"left\">Retail product items</th> <td width=\"3%\"> </td> <td width=\"8%\"> </td> <td width=\"3%\"> </td> <th width=\"35%\" align=\"left\">Base items</th> </tr> <tr> <td><select name=\"lst_rpitems\" size=\"10\"> </select></td> <td> </td> <td align=\"center\"><input name=\"submit\" type=\"submit\" value=\"<<\" onclick=\" return check()\" /><br /><br /><input name=\"submit\" type=\"submit\" value=\">>\" /></td> <td> </td> <td><select name=\"lst_baseitems\" size=\"10\">"; $qry2 = "SELECT * FROM basetbl ORDER BY baseName"; $rez = $conn->query($qry2); while($rec = $conn->fetchArray($rez)) { $bname = $rec['baseName']; $bid = $rec['baseID']; $vid = $rec['volID']; $mid = $rec['measureID']; $qry = "SELECT vol FROM volumetbl WHERE volID = '$vid'"; $res = $conn->query($qry); while($vrec = $conn->fetchArray($res)) { $vol = $vrec['vol']; } $msql = "SELECT measure FROM measuretbl WHERE measureID = '$mid'"; $mres = $conn->query($msql); while($mrec = $conn->fetchArray($mres)) { $meas = $mrec['measure']; } $show .= "<option value= \"$bid\">$bname ($vol $meas)</option>"; } $show .= "</select></td> </tr> </table> <table width=\"70%\"> <tr> <td> </td> <td> </td> </tr> <tr> <th align=\"left\">Price:</th> <td><input name=\"txPrice\" type=\"text\" size=\"10\"/> </td> </tr> <tr> <th width=\"20%\" align=\"left\">Price effective from:</th> <td width=\"60%\"><select name=\"sel_yearPF\">"; include_once 'date.php'; for($x = 0; $x < count($year); $x++) { $show .= "<option value=\"$year[$x]\"> $year[$x]</option>"; } $show .= "</select> <select name=\"sel_monthPF\">"; for($x = 0; $x < count($months); $x++) { $show .= "<option value=\"$months[$x]\"> $months[$x]</option>"; } $show .= "</select> <select name=\"sel_dayPF\">"; for($x = 0; $x < count($days); $x++) { $show .= "<option value=\"$days[$x]\"> $days[$x]</option>"; } $show .= "</select> : <select name=\"sel_hrsPF\">"; for($x = 0; $x < count($hours); $x++) { $show .= "<option value=\"$hours[$x]\"> $hours[$x]</option>"; } $show .= "</select> <select name=\"sel_minsPF\">"; for($x = 0; $x < count($mins); $x++) { $show .= "<option value=\"$mins[$x]\"> $mins[$x]</option>"; } $show .= "</select></td> </tr> <tr> <th align=\"left\">Price effective to:</th> <td><select name=\"sel_year_pto\">"; for($x = 0; $x < count($year); $x++) { $show .= "<option value=\"$yearto[$x]\"> $yearto[$x]</option>"; } $show .= "</select> <select name=\"sel_month_pto\">"; for($x = 0; $x < count($months); $x++) { $show .= "<option value=\"$months[$x]\"> $months[$x]</option>"; } $show .= "</select> <select name=\"sel_day_pto\">"; for($x = 0; $x < count($days); $x++) { $show .= "<option value=\"$days[$x]\"> $days[$x]</option>"; } $show .= "</select> : <select name=\"sel_hrs_pto\">"; for($x = 0; $x < count($hours); $x++) { $show .= "<option value=\"$hours[$x]\"> $hours[$x]</option>"; } $show .= "</select> <select name=\"sel_mins_pto\">"; for($x = 0; $x < count($mins); $x++) { $show .= "<option value=\"$mins[$x]\"> $mins[$x]</option>"; } $show .= "</select></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <th width=\"20%\" align=\"left\">Date effective from:</th> <td width=\"60%\"><select name=\"sel_yearAF\">"; for($x = 0; $x < count($year); $x++) { $show .= "<option value=\"$year[$x]\"> $year[$x]</option>"; } $show .= "</select> <select name=\"sel_monthAF\">"; for($x = 0; $x < count($months); $x++) { $show .= "<option value=\"$months[$x]\"> $months[$x]</option>"; } $show .= "</select> <select name=\"sel_dayAF\">"; for($x = 0; $x < count($days); $x++) { $show .= "<option value=\"$days[$x]\"> $days[$x]</option>"; } $show .= "</select> : <select name=\"sel_hrsAF\">"; for($x = 0; $x < count($hours); $x++) { $show .= "<option value=\"$hours[$x]\"> $hours[$x]</option>"; } $show .= "</select> <select name=\"sel_minsAF\">"; for($x = 0; $x < count($mins); $x++) { $show .= "<option value=\"$mins[$x]\"> $mins[$x]</option>"; } $show .= "</select></td> </tr> <tr> <th align=\"left\">Date effective to:</th> <td><select name=\"sel_year_ato\">"; for($x = 0; $x < count($year); $x++) { $show .= "<option value=\"$yearto[$x]\"> $yearto[$x]</option>"; } $show .= "</select> <select name=\"sel_month_ato\">"; for($x = 0; $x < count($months); $x++) { $show .= "<option value=\"$months[$x]\"> $months[$x]</option>"; } $show .= "</select> <select name=\"sel_day_ato\">"; for($x = 0; $x < count($days); $x++) { $show .= "<option value=\"$days[$x]\"> $days[$x]</option>"; } $show .= "</select> : <select name=\"sel_hrs_ato\">"; for($x = 0; $x < count($hours); $x++) { $show .= "<option value=\"$hours[$x]\"> $hours[$x]</option>"; } $show .= "</select> <select name=\"sel_mins_ato\">"; for($x = 0; $x < count($mins); $x++) { $show .= "<option value=\"$mins[$x]\"> $mins[$x]</option>"; } $show .= "</select></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><input name=\"submit\" type=\"submit\" value=\"Save\" /> <input name=\"submit\" type=\"submit\" value=\"Cancel\" /></td> <td> </td> </tr> </table> </form>"; } } else { $out = "<center>Your session has timed out, please <a href=\"index.htm\"><font color=\"#FFFFFF\" size=\"+2\">Login</font></a></center>"; } //---------------------------------------------------------------------------------------------------------------- if(isset($_SESSION['username'])) { $div .= "<div align=\"right\"><a href=\"logout.php\"><font color=\"#FFFFFF\" size=\"+1\">Logout</font></a> or <a href=\"menu.php\"><font color=\"#FFFFFF\" size=\"+1\">Menu</font></a></div>"; $show = $div.$show; echo $show; } else { echo $out; } ?> and the include is: <?php $disql = "SELECT * FROM temp_retail LIMIT 1"; $rr = $conn->query($disql); while($recz = $conn->fetchArray($rr)) { $grname = $recz['grpName']; $rpname = $recz['rpName']; } $form = "<form action=\"$_SERVER[php_SELF]\" method=\"post\" name=\"fmRetail\"> <table width=\"35%\"> <tr> <th align=\"left\">Group:</th> <td><input name=\"sel_grp\" type=\"text\" size=\"30\" value=\"$grname\" disabled /><input type=\"hidden\" name=\"hdGrp\" value=\"$grname\" /></td> </tr> <tr> <th align=\"left\">Retail product name:</th> <td><input name=\"name\" type=\"text\" size=\"30\" value=\"$rpname\" disabled /><input type=\"hidden\" name=\"hdRp\" value=\"$rpname\" /></td> </tr> </table> <br /> <br /> <table width=\"70%\"> <tr> <td width=\"35%\">Retail product items</td> <td width=\"3%\"> </td> <td width=\"8%\"> </td> <td width=\"3%\"> </td> <td width=\"35%\">Base items</td> </tr> <tr> <td><select name=\"lst_rpitems\" size=\"10\">"; $sql2 = "SELECT rpItem, qty FROM temp_retail"; $result = $conn->query($sql2); while($rec = $conn->fetchArray($result)) { $item = $rec['rpItem']; $qty = $rec['qty']; $getsql = "SELECT * FROM basetbl WHERE baseID = '$item'"; $rezzz = $conn->query($getsql); while($rrr = $conn->fetchArray($rezzz)) { $name = $rrr['baseName']; $vid = $rrr['volID']; $mid = $rrr['measureID']; } $qry = "SELECT vol FROM volumetbl WHERE volID = '$vid'"; $res = $conn->query($qry); while($vrec = $conn->fetchArray($res)) { $vol = $vrec['vol']; } $msql = "SELECT measure FROM measuretbl WHERE measureID = '$mid'"; $mres = $conn->query($msql); while($mrec = $conn->fetchArray($mres)) { $meas = $mrec['measure']; } $dis = "(".$qty.")"." ".$item; $form .= "<option value= \"$item\">$qty x $name ($vol $meas)</option>"; } $form .= "</select></td> <td> </td> <td align=\"center\"><input name=\"submit\" type=\"submit\" value=\"<<\" /><br /><br /><input name=\"submit\" type=\"submit\" value=\">>\" /></td> <td> </td> <td><select name=\"lst_baseitems\" size=\"10\">"; $sql3 = "SELECT * FROM basetbl ORDER BY baseName"; $result = $conn->query($sql3); while($rec = $conn->fetchArray($result)) { $bname = $rec['baseName']; $bid = $rec['baseID']; $vid = $rec['volID']; $mid = $rec['measureID']; $qry = "SELECT vol FROM volumetbl WHERE volID = '$vid'"; $res = $conn->query($qry); while($vrec = $conn->fetchArray($res)) { $vol = $vrec['vol']; } $msql = "SELECT measure FROM measuretbl WHERE measureID = '$mid'"; $mres = $conn->query($msql); while($mrec = $conn->fetchArray($mres)) { $meas = $mrec['measure']; } $form .= "<option value= \"$bid\">$bname ($vol $meas)</option>"; } $form .= "</select></td> </tr> </table> <table width=\"70%\"> <tr> <td> </td> <td> </td> </tr> <tr> <th align=\"left\">Price:</th> <td><input name=\"txPrice\" type=\"text\" size=\"10\"/> </td> </tr> <tr> <th width=\"20%\" align=\"left\">Price effective from:</th> <td width=\"60%\"><select name=\"sel_yearPF\">"; include_once 'date.php'; for($x = 0; $x < count($year); $x++) { $form .= "<option value=\"$year[$x]\"> $year[$x]</option>"; } $form .= "</select> <select name=\"sel_monthPF\">"; for($x = 0; $x < count($months); $x++) { $form .= "<option value=\"$months[$x]\"> $months[$x]</option>"; } $form .= "</select> <select name=\"sel_dayPF\">"; for($x = 0; $x < count($days); $x++) { $form .= "<option value=\"$days[$x]\"> $days[$x]</option>"; } $form .= "</select> : <select name=\"sel_hrsPF\">"; for($x = 0; $x < count($hours); $x++) { $form .= "<option value=\"$hours[$x]\"> $hours[$x]</option>"; } $form .= "</select> <select name=\"sel_minsPF\">"; for($x = 0; $x < count($mins); $x++) { $form .= "<option value=\"$mins[$x]\"> $mins[$x]</option>"; } $form .= "</select></td> </tr> <tr> <th align=\"left\">Price effective to:</th> <td><select name=\"sel_year_pto\">"; for($x = 0; $x < count($year); $x++) { $form .= "<option value=\"$yearto[$x]\"> $yearto[$x]</option>"; } $form .= "</select> <select name=\"sel_month_pto\">"; for($x = 0; $x < count($months); $x++) { $form .= "<option value=\"$months[$x]\"> $months[$x]</option>"; } $form .= "</select> <select name=\"sel_day_pto\">"; for($x = 0; $x < count($days); $x++) { $form .= "<option value=\"$days[$x]\"> $days[$x]</option>"; } $form .= "</select> : <select name=\"sel_hrs_pto\">"; for($x = 0; $x < count($hours); $x++) { $form .= "<option value=\"$hours[$x]\"> $hours[$x]</option>"; } $form .= "</select> <select name=\"sel_mins_pto\">"; for($x = 0; $x < count($mins); $x++) { $form .= "<option value=\"$mins[$x]\"> $mins[$x]</option>"; } $form .= "</select></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <th width=\"20%\" align=\"left\">Date effective from:</th> <td width=\"60%\"><select name=\"sel_yearAF\">"; for($x = 0; $x < count($year); $x++) { $form .= "<option value=\"$year[$x]\"> $year[$x]</option>"; } $form .= "</select> <select name=\"sel_monthAF\">"; for($x = 0; $x < count($months); $x++) { $form .= "<option value=\"$months[$x]\"> $months[$x]</option>"; } $form .= "</select> <select name=\"sel_dayAF\">"; for($x = 0; $x < count($days); $x++) { $form .= "<option value=\"$days[$x]\"> $days[$x]</option>"; } $form .= "</select> : <select name=\"sel_hrsAF\">"; for($x = 0; $x < count($hours); $x++) { $form .= "<option value=\"$hours[$x]\"> $hours[$x]</option>"; } $form .= "</select> <select name=\"sel_minsAF\">"; for($x = 0; $x < count($mins); $x++) { $form .= "<option value=\"$mins[$x]\"> $mins[$x]</option>"; } $form .= "</select></td> </tr> <tr> <th align=\"left\">Date effective to:</th> <td><select name=\"sel_year_ato\">"; for($x = 0; $x < count($year); $x++) { $form .= "<option value=\"$yearto[$x]\"> $yearto[$x]</option>"; } $form .= "</select> <select name=\"sel_month_ato\">"; for($x = 0; $x < count($months); $x++) { $form .= "<option value=\"$months[$x]\"> $months[$x]</option>"; } $form .= "</select> <select name=\"sel_day_ato\">"; for($x = 0; $x < count($days); $x++) { $form .= "<option value=\"$days[$x]\"> $days[$x]</option>"; } $form .= "</select> : <select name=\"sel_hrs_ato\">"; for($x = 0; $x < count($hours); $x++) { $form .= "<option value=\"$hours[$x]\"> $hours[$x]</option>"; } $form .= "</select> <select name=\"sel_mins_ato\">"; for($x = 0; $x < count($mins); $x++) { $form .= "<option value=\"$mins[$x]\"> $mins[$x]</option>"; } $form .= "</select></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><input name=\"submit\" type=\"submit\" value=\"Save\" /> <input name=\"submit\" type=\"submit\" value=\"Cancel\" /></td> <td> </td> </tr> </table> </form>"; ?> Link to comment https://forums.phpfreaks.com/topic/38444-php-and-javascript/#findComment-184529 Share on other sites More sharing options...
JasonLewis Posted February 15, 2007 Share Posted February 15, 2007 i dont see any place where you are calling the javascrpt in that. either add the onsubmit in the form tag or onclick n the submit tag. there isnt really a difference between the two by the way. Link to comment https://forums.phpfreaks.com/topic/38444-php-and-javascript/#findComment-185306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.