...

View Full Version : question about select tag



sudhakararaog
01-09-2008, 09:55 PM
i have a register.php and confirmregister.php file. in the first file the user fills a registeration form and in the second page they can review what they

entered in the first page and then confirm their registration. in the register.php a user can select their area code for the phone number from a drop down

<select name="pcontactnumber">
<option value="09"> <option value="07"> <option value="06">
</select>

now in the confirmregister.php file when i use the following code whatever the user selects as the area code the confirm.php file displays the area code in a

drop down
<select name="pcontactnumber">
<option SELECTED value="09"><?php echo $pcontactnumber; ?></option>
<option SELECTED value="07"><?php echo $pcontactnumber; ?></option>
<option SELECTED value="06"><?php echo $pcontactnumber; ?></option>
</select>

however what i have noticed is in the confirmregister.php page if i again click on this select menu to lets say change the area code, the drop down consists

of a list of options with the number that was choosen in the register.php page as in the source code in confirmregister.php would look like

<select name="pcontactnumber">
<option SELECTED value="09">09</option>
<option SELECTED value="07">09</option>
<option SELECTED value="06">09</option>
</select> assuming 09 was selected in the register.php page.

please advice how i can display the list as it is in the register.php file without the same number repeating in confirmregister.php

thanks.

o0O0o.o0O0o
01-09-2008, 11:50 PM
drop down
<select name="pcontactnumber">
<option SELECTED value="09"><?php echo $pcontactnumber; ?></option>
<option SELECTED value="07"><?php echo $pcontactnumber; ?></option>
<option SELECTED value="06"><?php echo $pcontactnumber; ?></option>
</select>

Thats because you r displaying the same values

just copy paste combob box from the register.php no need to use echo statement

I think in the confirm.php , you should display only what the user has selected in simple htnl display , no comobox are required in confirm.php , if user wants to change then they can go back

Rest depends upon you

shyam
01-10-2008, 01:00 AM
<select name="pcontactnumber">
<option SELECTED value="09"><?php echo $pcontactnumber; ?></option>
<option SELECTED value="07"><?php echo $pcontactnumber; ?></option>
<option SELECTED value="06"><?php echo $pcontactnumber; ?></option>
</select>


as rightly pointed out by o0O0o.o0O0o ur echoing out the same number...and unless u have a multiple-select the first option will be selected by default...

i think what u are actually looking at is something like this


<select>
<option value="07" <?php echo ('07' == $pcontactnumber) ? 'selected="selected"' : '' ?>>07</option>
...
</select>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum