我們已經設置了2個下拉菜單。一旦用戶選擇了下拉選項1和選項下拉選項2,一旦選擇並且他們點擊提交按鈕,我們就需要它進入一個頁面。帶鏈接的動態下拉菜單
目前代碼設置爲彈出窗口並顯示不是我們想要的URL名稱。
希望能儘快聽到某人的解答。
感謝, 馬塞洛
<script>
function setOptions(chosen) {
var selbox = document.myform.opttwo;
selbox.options.length = 0;
if (chosen == " ") {
selbox.options[selbox.options.length] =
new Option('Please select one of the options above first',' ');
}
if (chosen == "1") {
selbox.options[selbox.options.length] =
new Option('UV Protection','http://example.com/portfolio-item/hand-cream-frag-free/');
selbox.options[selbox.options.length] =
new Option('Acne','http://example.com/portfolio-item/hand-cream-frag-free/');
selbox.options[selbox.options.length] =
new Option('Dry Skin','http://example.com/portfolio-item/hand-cream-frag-free/');
selbox.options[selbox.options.length] =
new Option('Eczema','http://example.com/portfolio-item/hand-cream-frag-free/');
selbox.options[selbox.options.length] =
new Option('Itchy Relief','http://example.com/portfolio-item/hand-cream-frag-free/');
selbox.options[selbox.options.length] =
new Option('Redness','http://example.com/portfolio-item/hand-cream-frag-free/');
selbox.options[selbox.options.length] =
new Option('Sensitive Skin','http://example.com/portfolio-item/hand-cream-frag-free/');
}
if (chosen == "2") {
selbox.options[selbox.options.length] =
new Option('UV Protection','http://example.com/portfolio-item/foot-balm/');
selbox.options[selbox.options.length] =
new Option('Acne','http://example.com/portfolio-item/foot-balm/');
selbox.options[selbox.options.length] =
new Option('Dry Skin','http://example.com/portfolio-item/foot-balm/');
selbox.options[selbox.options.length] =
new Option('Eczema','http://example.com/portfolio-item/foot-balm/');
selbox.options[selbox.options.length] =
new Option('Itchy Relief','http://example.com/portfolio-item/foot-balm/');
selbox.options[selbox.options.length] =
new Option('Redness','http://example.com/portfolio-item/foot-balm/');
selbox.options[selbox.options.length] =
new Option('Sensitive Skin','http://example.com/portfolio-item/foot-balm/');
}
if (chosen == "3") {
selbox.options[selbox.options.length] =
new Option('UV Protection','http://example.com/portfolio-item/body-lotion/');
selbox.options[selbox.options.length] =
new Option('Acne','http://example.com/portfolio-item/body-lotion/');
selbox.options[selbox.options.length] =
new Option('Dry Skin','http://example.com/portfolio-item/body-lotion/');
selbox.options[selbox.options.length] =
new Option('Eczema','http://example.com/portfolio-item/body-lotion/');
selbox.options[selbox.options.length] =
new Option('Itchy Relief','http://example.com/portfolio-item/body-lotion/');
selbox.options[selbox.options.length] =
new Option('Redness','http://example.com/portfolio-item/body-lotion/');
selbox.options[selbox.options.length] =
new Option('Sensitive Skin','http://example.com/portfolio-item/body-lotion/');
}
}
</script>
<form name="myform"><div class="centre">
<select name="optone" size="1"
onchange="setOptions(document.myform.optone.options[ document.myform.optone.selectedIndex].value);">
<option value=" " selected="selected">I am</option>
<option value="1">Someone who works with my hands</option>
<option value="2">Someone who works with my feet</option>
<option value="3">Someone who works with my body</option>
</select><br /> <br />
<select name="opttwo" size="1">
<option value=" " selected="selected">and I need</option>
</select>
<input type="button" name="go" value="Value Selected"
onclick="alert(document.myform.opttwo.options[ document.myform.opttwo.selectedIndex].value);">
</div></form>
歡迎來到StackOverflow。將來,請務必將您的問題稱爲**問題**。你的帖子沒有提出問題,但我回答了你所問的**。 – philtune 2014-12-03 21:16:22