开发者

in a form when i select the input value it should take me to the new page in a new window

开发者 https://www.devze.com 2023-01-13 22:02 出处:网络
开发者_开发技巧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:

开发者_开发技巧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()">
0

精彩评论

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