onchange function not working [closed]
<script type="text/javascript">
function urlchange() {
var val = document.getElementById('fix');
e = val.options[val.selectedIndex].value;
window.open('e','mywindow','width=500,height=500')
}
</script>
</head>
<body>
<select id="fix" onblur="urlchange()">
<option selected="selected">select</option>
<option value="http://www.airtel.in">airtel</option开发者_开发百科>
<option value="http://google.in">google</option>
</select>
</body>
</html>
You have write this code to fire when it's blurred....!!! If You want onchange then try this:
<script type="text/javascript">
function urlchange() {
var val= document.getElementById('fix');
e=val.options[val.selectedIndex].value;
window.open(e,'mywindow','width=500,height=500')
}
</script>
<select id="fix" onchange="urlchange()">
<option selected="selected">select</option>
<option value="http://www.airtel.in">airtel</option>
<option value="http://google.in">google</option>
</select>
Don't put quotes around the variable.
window.open(e,'mywindow','width=500,height=500')
If you do it will try to navigate the new window to 'e' instead of the url in the html.
http://jsfiddle.net/9cMRq/
精彩评论