2016-09-22 74 views
0

Hello everyone! I just want to ask, when I choose regular in my drop down. The link goes to the regular.html as well as the contractual. How can I do it? Thank you in advance. :)当点击/选择一个选项,指定该选项的链接将继续

而且这里是我的regular.html代码: regular.html

<html> 
<head> 
    <title>Drop down</title> 
</head> 
<body> 
    <h1>Regular</h1> 
    <select> 
     <option href="regular.html">Regular</option> 
     <option href="contractual.html">Contractual</option> 
    </select> 
</body> 
</html> 

这是合同: contractual.html

<html> 
<head> 
    <title>Drop down</title> 
</head> 
<body> 
    <h1>Contractual</h1> 
    <select> 
     <option href="regular.html">Regular</option> 
     <option href="contractual.html">Contractual</option> 
    </select> 
</body> 
</html> 
+1

请参考[链接] http://stackoverflow.com/questions/10175445/load-page-on-selection-from-dropdown-form – Aswathy

+0

你想到底该怎么做? – Lakhan

回答

0
<h1>Main Page</h1> 
    <select onchange="location = this.options[this.selectedIndex].value;"> 
     <option value="regular.html">Regular</option> 
     <option value="contractual.html">Contractual</option> 
    </select> 
+0

谢谢你的回答。它工作完美。谢谢。 :) –

0

你可以试试这个:

$('select').change(function(){ 
    var url = $('option:selected', this).attr('href'); 
    window.location.href = url; 
}); 
+0

在代码 –

+1

之前加载jquery''感谢您的回答。我感谢你的努力。再次感谢你。 :) –

+0

@FrancisVargas:为什么这个答复会被下调? – Lakhan

相关问题