Reputation: 19
here is what i came up, i could insert a data into my "gender" field, but when I'm in edit/update page, i want the "gender" field only displays "Select One" value, not "male/Female"
thanks in advance
<form action='#' method='post' border='0'>
<table>
<tr>
<td>
<select name="gender" id="gender">
<option>Select One</option>
<option>Male</option>
<option>Female</option>
</select>
</td>
</tr>
<td>
<input type='hidden' name='id_number' value='<? php echo $id_number ?>' />
<input type='hidden' name='action' value='edit' />
<input type='submit' value='Edit' />
</td>
</table>
</form>
Upvotes: 0
Views: 985
Reputation: 28763
Simply import the $gender value from the db into the edit page and then add this :
<select name="gender" id="gender">
<option>Select One</option>
<option <?if $gender=="Male" echo 'selected="selected"'?>>Male</option>
<option <?if $gender=="Female" echo 'selected="selected"'?>>Female</option>
</select>
Thats it friend.I hope it will useful for you much
Upvotes: 0
Reputation: 58770
You have to add an attribute named selected="selected"
to the <option>
tag that you want selected by default.
Upvotes: 1