开发者_开发技巧I have a form and i have the input values say google microsoft
On selection of the input value google i want to open a new google page in the new window. how i can get that.
HTML code:
<html>
<body>
<script>
function openAnotherWin(combo) {
var v = combo.value;
window.open(v);
}
</script>
<select name="sites" onchange="openAnotherWin(this)">
<option value="">Select one site...</option>
<option value="http://www.google.com">Google</option>
<option value="http://www.microsoft.com">Microsoft</option>
</select>
</body>
</html>
Test site: http://jsfiddle.net/JU4p3/
you should add an "onchange" event to the input field
<script type="text/javascript">
<!--
function onChangeExample(){
window.location = "http://www.google.com/"
}
//-->
</script>
<input type="text" id="example" onchange="onChangeExample()">
精彩评论