Welcome Guest, Not a member yet? Register   Sign In
HTML Select Problem
#1

[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.
#2

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

[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.
#4

[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.
#5

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




Theme © iAndrew 2016 - Forum software by © MyBB