Tuesday, 27 August 2013

Getting a val from an option tag inside a form. CodeIgniter

Getting a val from an option tag inside a form. CodeIgniter

The similar questions out there didnt really help me because they were too
specific.
I have a form with a select input. I need the val that accompies the
option tags.
When I var_dump the post data, I can see that the data being transferred
is not the val of the option, but the name of the option.
i.e:
<select name="selector">
<option val="1">Option 1</option>
<option val="2">Option </option>
</select>
And my post data will say something like ["selector"]=> string(8) "Option 1"
I'm using CodeIgniter and I'm not sure how to get it to play along.
I want to avoid doing something convoluted with JavaScript and getting the
.val() and assigning it to something else. That would be lame.

No comments:

Post a Comment