![](/img/trans.png)
[英]I tried to add a Bootstrap dropdown button to <a> but the dropdown menu wont work. How do I do this?
[英]How do I follow dynamic url with DropDown Value onClick Button - why wont this work?
我看到过类似的帖子,但是一个答案使用了ajax,而另一个答案使用了表单/帖子。 我不知道为什么这行不通。 感谢您的解释-干杯。
<script >
<select name="region" id="region" tags="region">
<?php echo $regionList; ?>
</select>
function getQuote(){
e = document.getElementById("region");
region = e.options[e.selectedIndex].value;
linkTarget = "http://tatgeturlpage.com' + '?region=' + region ";
return "window.location=" + linkTarget;
}
</script>
<input type="button" onclick="getQuote()" value="Get Quote">
您的“区域”变量将被读取为字符串,而不是所选值。 因此,更改此行:
linkTarget = "http://tatgeturlpage.com' + '?region=' + region ";
至:
linkTarget = "http://tatgeturlpage.com?region=" + region;
您不能将select语句放在脚本标签内。 浏览器将忽略它们。 尝试将它们移动到脚本上方或下方。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.