Jump to content

Recommended Posts

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
Link to comment
https://forums.phpfreaks.com/topic/5901-drop-down-menu/
Share on other sites

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?
Link to comment
https://forums.phpfreaks.com/topic/5901-drop-down-menu/#findComment-21064
Share on other sites

[!--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,
Link to comment
https://forums.phpfreaks.com/topic/5901-drop-down-menu/#findComment-21070
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.