2016-09-22 31 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

相關問題