eits Posted September 9, 2007 Share Posted September 9, 2007 Hi everybody! I have the following code which I am using to get customer names from a database. I have the dropdown on a form but when I click submit I have to press it twice as the first time I do it all the data seems to go from the page. Is there anything strange any of you can see here as when I remove it I do not have to press submit twice. (Doesnt help when I remove JS onchange event either - definitely not this) Thanks <select name="clientdd" id="clientdd" onChange="formHandler()"> <?php do { ?> <option value="<?php echo $row_custdb['clientname']?>" selected=""> <?php echo $row_custdb['clientname']?> </option> <?php } while ($row_custdb = mysql_fetch_assoc($custdb)); $rows = mysql_num_rows($custdb); if($rows < 10) { mysql_data_seek($custdb, 0); $row_custdb = mysql_fetch_assoc($custdb); } ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/68576-help-with-this-selectbox-code/ Share on other sites More sharing options...
pranav_kavi Posted September 9, 2007 Share Posted September 9, 2007 pls post the entire code specially d form section Quote Link to comment https://forums.phpfreaks.com/topic/68576-help-with-this-selectbox-code/#findComment-344703 Share on other sites More sharing options...
eits Posted September 9, 2007 Author Share Posted September 9, 2007 Form Code: <form id="form1" name="form1" method="post" action="<?php echo $editFormAction; ?>"> <table width="300" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <td width="118">Client Name </td> <td width="168"> <select name="clientdd" id="clientdd" onChange="formHandler()"> <?php do { ?> <option value="<?php echo $row_custdb['clientname']?>" selected=""> <?php echo $row_custdb['clientname']?> </option> <?php } while ($row_custdb = mysql_fetch_assoc($custdb)); $rows = mysql_num_rows($custdb); if($rows < 10) { mysql_data_seek($custdb, 0); $row_custdb = mysql_fetch_assoc($custdb); } ?> </select></td> </tr> <tr> <td>Job Number </td> <td><label> <select name="jobnumdd" id="jobnumdd"> <?php do { ?> <option value="<?php echo $row_jobdb['jobnumber']?>" selected="<?php $row_jobdb['jobnumber'] ?>"> <?php echo $row_jobdb['jobnumber']?></option> <?php } while ($row_jobdb = mysql_fetch_assoc($jobdb)); $rows = mysql_num_rows($jobdb); if($rows < 10) { mysql_data_seek($jobdb, 0); $row_jobdb = mysql_fetch_assoc($jobdb); } ?> </select> </label></td> </tr> <tr> <td>Hours Worked </td> <td><label> <input name="flhourstoday" type="text" id="flhourstoday" value="0:00" /> </label></td> </tr> <tr> <td>Remaining Hours</td> <td><label> <input name="flremhours" type="text" id="flremhours" value="<?php echo $hoursremaining; ?>"> </label></td> </tr> <tr> <td colspan="2"><label> <input type="submit" name="Submit" value="Submit" /> </label></td> </tr> </table> <p> <input type="hidden" name="clientid" value="<?php echo $row_custdb['clientid']; ?>" /> <input type="hidden" name="clientname" value="<?php echo $_POST['clientdd']; ?>" /> <input type="hidden" name="hoursleft" value="<?php echo $row_custdb['hoursleft']; ?>" /> <input type="hidden" name="hoursallocated" value="<?php echo $row_custdb['hoursallocated']; ?>" /> <input type="hidden" name="hoursworked" value="<?php echo $row_custdb['hoursworked'] + hourstodecimal($_POST['flhourstoday']); ?>" /> <input type="hidden" name="jobid" value="<?php echo $row_jobdb['jobid']; ?>" /> <input name="jobnumber" type="hidden" id="jobnumber" value="<?php echo $_POST['jobnumdd']; ?>" /> <input name="timeonjob" type="hidden" id="timeonjob" value="<?php echo $row_jobdb['timeonjob'] + $_POST['flhourstoday']; ?>" /> </p> </form> More Code: $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE tblcustomer SET clientname=%s, hoursworked=%s, hoursleft=%s, hoursallocated=%s WHERE clientid=%s", GetSQLValueString($_POST['clientname'], "text"), GetSQLValueString($_POST['hoursworked'], "text"), GetSQLValueString($_POST['hoursleft'], "text"), GetSQLValueString($_POST['hoursallocated'], "text"), GetSQLValueString($_POST['clientid'], "int")); mysql_select_db($database_timedb, $timedb); $Result1 = mysql_query($updateSQL, $timedb) or die(mysql_error()); print 'Query Ran: '.$updateSQL.' Result: '.$Result1; } : Quote Link to comment https://forums.phpfreaks.com/topic/68576-help-with-this-selectbox-code/#findComment-344706 Share on other sites More sharing options...
eits Posted September 9, 2007 Author Share Posted September 9, 2007 bump* Quote Link to comment https://forums.phpfreaks.com/topic/68576-help-with-this-selectbox-code/#findComment-344751 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.