jamesnkk Posted March 27, 2006 Share Posted March 27, 2006 Hi,I have an entry form that contain some text entry and one drop down menu which I retrieve the data from a table.The problem is when I click the submit button, It go to the 2nd form to validate for error, if error it will return to the entry form, I could manage to retain all text entry, so that user donlt have to re-type all over again.But I cannot retain the selected item from a drop down menu, is there a way ?, please help me.Thanks Quote Link to comment Share on other sites More sharing options...
micah1701 Posted March 27, 2006 Share Posted March 27, 2006 what method are you using to re-populate the text field? if your are just echoing the posted values (value="<? echo $_POST['value'] ?>") then for the drop down just do:<select name="dropdown"> <option value="option1" <? if($_POST['dropdown'] == 'option1'){ echo "selected"; } ?>> Option 1 </option> <option value="option2" <? if($_POST['dropdown'] == 'option2'){ echo "selected"; } ?>> Option 2 </option> <option value="option3" <? if($_POST['dropdown'] == 'option3'){ echo "selected"; } ?>> Option 3 </option></select>get the idea? Quote Link to comment Share on other sites More sharing options...
jamesnkk Posted March 27, 2006 Author Share Posted March 27, 2006 [!--quoteo(post=358756:date=Mar 27 2006, 11:25 AM:name=micah1701)--][div class=\'quotetop\']QUOTE(micah1701 @ Mar 27 2006, 11:25 AM) [snapback]358756[/snapback][/div][div class=\'quotemain\'][!--quotec--]what method are you using to re-populate the text field? if your are just echoing the posted values (value="<? echo $_POST['value'] ?>") then for the drop down just do:<select name="dropdown"> <option value="option1" <? if($_POST['dropdown'] == 'option1'){ echo "selected"; } ?>> Option 1 </option> <option value="option2" <? if($_POST['dropdown'] == 'option2'){ echo "selected"; } ?>> Option 2 </option> <option value="option3" <? if($_POST['dropdown'] == 'option3'){ echo "selected"; } ?>> Option 3 </option></select>get the idea?[/quote]Thanks for the prompt reply, here the code to populate from a table on form-1(create_partno.php)<select name="aid" id="aid" size="1"> <option selected value="">Please select</option> <? while ($company = mysql_fetch_array($companys) ) { $aid=$company['company']; $aname=htmlspecialchars($company['company']); echo "<option value='$aid'>$aname</option>\n"; } ?> </select>Then on the 2nd form (create_part.php) I use header to return, - header("Location: create_partno.php?part_no=".$_POST['part_no']."&supp_partno=".$_POST['supp_partno']."&part_desp=".$_POST['part_desp'] ."&cost_price=".$_POST['cost_price']."&sell_price=".$_POST['sell_price'] ."&brand=".$_POST['brand']."&package=".$_POST['package']."&qty_bal=".$_POST['qty_bal'] ."$aid=".$_POST[aid] ."&qty_order=".$_POST['qty_order']."&re_order=".$_POST['re_order']."&error=".$_POST['error'].$error1 ); When return to form-1, Just could not retain the selected value from the drop down menu, Quote Link to comment 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.