开发者

onchange function not working [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.
<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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜