...

View Full Version : Editing User Info



CoolAsCarlito
01-21-2009, 07:12 PM
Here's a question what if I have an edit script that gets the users info and in that form has a drop down select menu. How do I get it to have the current value they are already selected?



print '<tr>';
print '<td class=rowheading>Account:</td>';
print '<td class=row3><select name=enabled class=selection>';
print '<option value=1>Enabled<option value=0>Disabled</option>';
print '</select></td>';
print '</tr>';

Common
01-21-2009, 07:52 PM
If you put selected="selected" into the <option> tag that'll do as you ask. As for implementing, a simple:

if($current_info == "this"){
echo "<option value=\"selected\">";
}

kinda thing would do, you could put it in a function then wrap it round each one. I'm sure there'll be a more efficient (probably involving loops...) method, but this is how I do it.

Edit: Btw, in case you didn't notice you'll need a </option> after "Enabled".



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum