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
    New Coder
    Join Date
    May 2009
    Posts
    48
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Dropdown box edit issue...

    Hello everyone,

    Below I have a HTML code with a bit of PHP that is only calling its partners in crime so to speak. That is not the priority here, the edit code works fine for any textboxes that needs editing, but is not for the drop down boxes. Let me explain further...

    In a previous page, I will set the dropdown box to ex: Spring 2011, and that accepts correctly in the database. It even carries over fine with the example textbox I placed in the code below. But the dropdown box defaults to the first item in the list, which would be Fall 2010. Now I can change this and submit with either the example textbox or even the dropdown box and it will work, that is not the issue. My issue is that the dropdown box will not keep the value that is stored in the database, but the textbox example will. I will explain my idea I have for overcoming this...

    I was thinking if I use a hidden textbox to receive the value, and then somehow (my problem) have the dropdown box which has the same name as the textbox be set so it reads the textbox and changes to that value. Does anyone have an idea on how I can get this to work? Any thought on this topic would be a great asset to me finishing this dilemma.

    Here is the basic HTML code below...

    Code:
    <select name="ship_season" class="textBox_center" id="ship_season" style="min-width:200px;" value="<?php echo $ship_season; ?>">
                        <option value="Fall 2010">Fall 2010</option>
                        <option value="Spring 2010">Spring 2010</option>
                        <option value="Fall 2011">Fall 2011</option>
                        <option value="Spring 2011">Spring 2011</option>
                      </select>
                      <input name="ship_season" id="ship_season" value="<?php echo $ship_season; ?>"/>
    Thank you all so much.

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,371
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    How about this idea ...

    PHP Code:
    <select name="ship_season" class="textBox_center" id="ship_season" style="min-width:200px;" value="<?php echo $ship_season?>">
                        <option value="<?php echo $ship_season?>"><?php echo $ship_season?></option>
                        <option value="Fall 2010">Fall 2010</option>
                        <option value="Spring 2010">Spring 2010</option>
                        <option value="Fall 2011">Fall 2011</option>
                        <option value="Spring 2011">Spring 2011</option>
                      </select>
                      <input name="ship_season" id="ship_season" value="<?php echo $ship_season?>"/>

  • #3
    New Coder
    Join Date
    May 2009
    Posts
    48
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you for the above post. I tried that but it won't carry new values from the database.

    Regardless, the code is working now. I took this approach and it works splendit!

    Code:
    <option value="Fall 2010" <?php if($ship_season == "Fall 2010") {echo " selected"; }?>>Fall 2010</option>                    
    <option value="Spring 2010"<?php if($ship_season == "Spring 2010") {echo " selected"; }?>>Spring 2010</option>                    
    <option value="Fall 2011"<?php if($ship_season == "Fall 2011") {echo " selected"; }?>>Fall 2011</option>                    
    <option value="Spring 2011"<?php if($ship_season == "Spring 2011") {echo " selected"; }?>>Spring 2011</option>
    Thank you!


  •  

    Posting Permissions

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