By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

Get a drop down value

LuiePL
P: 24
I'm trying to get the value the user selected in my drop down box.

This is the code for the box:

[HTML]<select size='1' name='Location' onchange="javascript:stateChange()">
<option value="California">California</option>
<option value="New Jersey">New Jersey</option>
<option value="Pennsylvania">Pennsylvania</option>
</select>
<br /><div id='divState' style="width:100%;height:20"></div>[/HTML]

This is the function it calls:

[HTML]<script language="javascript">
<!--
function stateChange(State){
var myState = State;
var str = "The state is: "+State;
document.getElementById("divState").innerHTML = str;
}
-->
</script>[/HTML]

I need to know what to put in the () of stateChange() when I call it. I haven't found anything that says what to do. I would think it would be something like 'Location.value', but that gives me "undefined" when I run it. Thanks for the help.
Sep 11 '06 #1
Share this Question
Share on Google+
1 Reply


LuiePL
P: 24
Got it. It's "this.value" but for some reason it wasn't working right before. Oh well...
Sep 11 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.