Reputation: 6353
I have a select box and I'm trying to get value of the selected option. I get error Property 'value' of object # is not a function
HTML:
<select id="my_SiteUsers" style="width:350px;" onchange="RefreshGroupLists()">
<option
value="i:0#.w|itun\akondruss_fg">Alex</option>
<option value="i:0#.w|itun\allepage_fg">Alex</option>
</select>
JS:
var e = document.getElementById("my_SiteUsers");
var user = e.value();
alert(user);
Upvotes: 0
Views: 1857
Reputation: 1050
Try using jquery's .val(), like many jq functions it will be (possibly) much easier than through js.
// Get the value from a dropdown select
$( "select.foo option:selected").val();
documentation: http://api.jquery.com/val/
edit-- looks like the above solution solved it more easily :)
Upvotes: 0
Reputation: 318192
value
is not a function, it's a property of the DOM node :
var e = document.getElementById("my_SiteUsers");
var user = e.value;
alert(user);
or with jQuery:
var user = $('#my_SiteUsers').val();
Upvotes: 2