Jump to content

Please Help: form list box....


avon267

Recommended Posts

Please Help: I want to update the list box form value!!!!!!!PLEASE HELP ME IN STEP 3

 

step 1:values displayed in form

<select name="optionlist">

<option value="Option 1" selected>Option 1</option>

<option value="Option 2">Option 2</option>

<option value="Option 3">Option 3</option>

<option value="Option 4">Option 4</option>

</select>

 

 

step 2:Saving value in db.

For example user selected option 2 and it get saved as " optionlist" = "option 2"

 

step 3: editing value

Please help.

How can I make "option 2" value as selected when I open form to update saved value "option 2", latter.

Link to comment
https://forums.phpfreaks.com/topic/137478-please-help-form-list-box/
Share on other sites

when editing, you first need to read the data from the db. i'll assume the info from the table for this value is stored in $optionlist.

<select name="optionlist">
<option value="Option 1" <?php if($optionlist == 'option 1') echo 'SELECTED'; ?>>Option 1</option>
<option value="Option 2" <?php if($optionlist == 'option 2') echo 'SELECTED'; ?>>Option 2</option>
<option value="Option 3" <?php if($optionlist == 'option 3') echo 'SELECTED'; ?>>Option 3</option>
<option value="Option 4" <?php if($optionlist == 'option 4') echo 'SELECTED'; ?>>Option 4</option>
</select>

 

i noticed that your values have a the first letter capitalized, but you store them lower case. not sure if that is supposed to be or not, but just make sure caps match up

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.