...

View Full Version : Dropdown box edit issue...



Wayniac
06-30-2010, 10:30 AM
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...


<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.

mlseim
06-30-2010, 12:30 PM
How about this idea ...



<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; ?>"/>

Wayniac
06-30-2010, 04:52 PM
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!


<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!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum