如何根據來自其他頁面的鏈接預先選擇下拉選項? 根據用戶點擊的鏈接,我需要在結果頁面上預先選擇合適的下拉索引。根據上一頁的鏈接創建從屬下拉菜單
第一頁:
<a href="http://somesite.com?mySelect=1">Option 1</a>
<a href="http://somesite.com?mySelect=2">Option 2</a>
<a href="http://somesite.com?mySelect=3">Option 3</a>
<a href="http://somesite.com?mySelect=4">Option 4</a>
第二頁代碼:
<select id="mySelect" name="mySelect">
<option>Select Option</option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
</select>
的JavaScript(第二頁):
<script type="text/javascript">
document.getElementById("mySelect").selectedIndex="**Appropriate Index**";
</script>
我想不出辦法以上JS傳遞到一個網址參數。上述代碼僅在與下拉菜單位於同一頁面時纔有效。 我需要添加到上面的JS爲了選擇和顯示正確的索引。