For instance, there’s a HTML select element identified by the ID #title, and after the user has selected one of the options, you want to get the text and value of the selected option.
<select id="title">
<option value="1">Mr</option>
<option value="2">Mrs</option>
<option value="3">Miss</option>
</select>
Now that the user has selected the 2nd option: Mrs. To get the value (in this case, ‘2’):
$("select#title").val();
Which is also the common function to return the value of all other form controls.
To get the text of the selected option (in this case, ‘Mrs’):
$("#title option:selected").text();


Facebook
Twitter
Google Plus
{ 5 comments… read them below or add one }
if i use jquery : get the text and value of selected option will it pass it on to an email if i have 3/4 email addresses for my options and send a comment etc to that selected address?
I can’t suggest a solution to this but you need a lot more to do that.
Can i use jQuery to check the value of a and if is chosen to show a new ?
User Scenario:
User chooses country; then then creates a new drop down box which will enable user to choose city.
Thanks in advance!
PedroO
Greetings!
I have a select inside a table cell. I need to get the value of the selected item into a PHP variable.
I have an Update button that initiates a database update of the values but it is not getting the selected value into the request array. I can use the $(“#title option:selected”).text(); stated above but I need to hook it to the Update button and then into a var to be passed to the next form.
Can you help me? Thanks in advance.
please refer to : http://www.longhowl.com/howls/179
{ 1 trackback }