Jump to content

killdozer

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

killdozer's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks ever so much dcro2, I have spent over a week, trying various solutions, sometimes you cannot see the forest for the trees, but I never knew about adding the select id. Thanks again
  2. Ok I changed it to this, but no change for the retention: echo "<form action='$_SERVER[php_SELF]' method='POST'>"; foreach($labels as $field => $label) { if($field == "state") { echo "<div class='province_state'><label for='state' size='15'>* Province/State</label><select name='state' id='state'>"; foreach($state_province as $state) { echo "<option value= $state"; if(@$_POST['state'] == $state) { echo "selected='selected'"; } echo ">"; echo $state; echo "</option>\n"; } echo "</select></div>\n"; }
  3. I'm stuck trying to figure out why when I make a selection in drop down list of a php form, the selection does not stay when form is refreshed or re-displayed due to an pattern error of another field. My array is state_province = array(list of the states, and provinces) field name in the label array is: "state" => "State", Here is the code that I'm using: echo "<form action='$_SERVER[php_SELF]' method='POST'>"; foreach($labels as $field => $label) { if($field == "state") { echo "<div class='province_state'><label for='state' size='15'>* Province/State</label><select>"; foreach($state_province as $state) { echo "<option value=$state"; if(@$_POST['state'] == $state) { echo "selected='selected'"; } echo ">"; echo $state; echo "</option>\n"; } echo "</select></div>\n"; }
  4. Thanks Guys, I tried both ways, but it still not retaining the selected state or province. I might have sent a slightly older file today, as I was at work. and never had access to my latest file. I attached the current file using "mjdamto" code here. I don't think I did a very good job naming the array, and the field one being state-province, the other state, as I would get confused to which I should use and where in the statement. Could you take a look at the attachment to see why it's not keeping the state/province as selected. I'm looking forward to your reply. [attachment deleted by admin]
  5. Hi I have a list of states using the array method in a form. The drop down menu works fine. I want to save the user choice,if the form is re-displayed due to a blank field or pattern mismatch. I know I can use the selected=selected, but don't know wher to put the statement: My array is: state_province = array ("list of states", "provinces") Var in my labels array is "state"=>"state" Here is my code for the select/option statement: { if($field == "state") { echo "<div class='province_state'><label for='state' size='10'>* Province/State</label><select>"; foreach($state_province as $state) { echo "\n<option value='$state_province' /> "; echo $state ; echo "</option>"; } echo "</select></div>\n"; } ?Is this the correct code to add and where would I add it? if(@$_POST['state'] == $value) { echo "selected='selected' "; } [attachment deleted by admin]
×
×
  • 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.