CodeIgniter Forums
HTML Select Problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: HTML Select Problem (/showthread.php?tid=24267)



HTML Select Problem - El Forum - 11-04-2009

[eluser]eric cumbee[/eluser]
i have several HTML Select dropdowns on the same page, used in slightly different contexts. they both use the same option data that is stored and echoed out of a php variable that was built from a database query.

The Problem i am running into is that one works and returns the selected value, while the other one only returns the value of the first option.

this is my markup for the one that works

Code:
<select name="Home_State" id="Home_State"/>
                &lt;?php echo $states;?&gt;
                </select>
This is my markup for the one that does not work

Code:
<select name="Mail_State" id="Mail_State">
                         &lt;?php echo $states;?&gt;
                    </select>
and then getting the form value using CI
Code:
$Mail_State = $this->input->post('Mail_State');
echo $Mail_State;
returns the value of the first option regardless of what option is selected.


HTML Select Problem - El Forum - 11-04-2009

[eluser]Ben Edmunds[/eluser]
Might want to use the form dropdown helper Smile


HTML Select Problem - El Forum - 11-04-2009

[eluser]eric cumbee[/eluser]
I am trying to keep the view as language/framework agnostic as possible. as it might also be needed in a non php/CI environment.


HTML Select Problem - El Forum - 11-04-2009

[eluser]Thorpe Obazee[/eluser]
You have a '/' in the first example you have. It's probably the reason why it is working. What does the $states variable contain. Could you paste it. There could be some markup problems with that.


HTML Select Problem - El Forum - 11-04-2009

[eluser]Thorpe Obazee[/eluser]
You could also check for other form inputs that have the same name. You might have left one with the same name. It happens to me sometimes.