I am working on an asp.net webapp, and in a view I have a drop down list that the user can select a value from. The drop down list works just fine-the right text is displayed in the menu. But, when I try and use some basic JS to capture the value, I get
“Uncaught TypeError: Object # has no method ‘GetElementById’ ” in the JS Console in Chrome. Here is my code:
<select id="stop" onchange="sendInfo();">
@foreach(var blah in ViewBag.foobar)
{
<option value=@blah>@blah</option>
}
</select>
<script>
function sendInfo() {
var stopId = document.GetElementById("stop").value;
}
</script>
Any help would be appreciated, I am very new to MVC and asp.net stuff.
Thanks,
Amanda
JavaScript is a case sensitive language and the method what your are looking for is getElementById
So you should write: