Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    137
    Thanks
    1
    Thanked 0 Times in 0 Posts

    question about select tag

    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.

  • #2
    Senior Coder o0O0o.o0O0o's Avatar
    Join Date
    Jan 2008
    Location
    C:\Windows\System32
    Posts
    1,018
    Thanks
    19
    Thanked 9 Times in 9 Posts
    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

  • #3
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    Quote Originally Posted by sudhakararaog View Post
    <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

    PHP Code:
    <select>
      <option value="07" <?php echo ('07' == $pcontactnumber) ? 'selected="selected"' '' ?>>07</option>
       ...
    </select>
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •