How Can I get selected text value from the combo box using jQuery.
I am having only "name" of combo box.
So, I want the text of selected item, using the name of combo box, not ID.
I am having ,
var selected_fld = ( $(this).attr('name') );
How can I proceed further ?
$('select[name=nameOfTheBox]').val();
or
$('select[name=nameOfTheBox] option:selected').val();
will give you the value of the selected option
$('select[name=nameOfTheBox] option:selected').text();
will give you its text
This can be done simply with the following to get the actual text value...
var value = $("[name='MyName'] option:selected").text();
or this to get the option 'value' attribute...
var value = $("[name='MyName']").val();
With the following html, the first will give you 'MyText', the second will give you 'MyValue'
<select name="MyName">
<option value="MyValue" selected="selected">MyText</option>
</select>
Here is a working example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With