Hi,
I am new to this and have a quick question:
Variable test is set to "0". When onchange is executed, the value of "test" is changed, and alert() function shows that.
But when it's written using document.write(test), it shows the original value "0".
How do I set it right with onchange?
Code:
<script type="text/javascript">
var test = 0;
</script>
<select onchange="var test = this.options[this.selectedIndex].value; alert(test);">
<option value="0"></option>
<option value="1">One</option>
<option value="2">Two</option>
<option value="3">Three</option>
</select>
<script type="text/javascript">
document.write(test);
</script>
Thank you!
|