我看到过类似的帖子,但有一个回答使用了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">
答案 0 :(得分:0)
您的&#34;地区&#34;变量读取为字符串而不是选定的值。所以改变这一行:
linkTarget = "http://tatgeturlpage.com' + '?region=' + region ";
要:
linkTarget = "http://tatgeturlpage.com?region=" + region;
答案 1 :(得分:0)
您不能在脚本标记内放置一个select语句。浏览器会忽略它们。尝试在脚本的上方或下方移动它们。