中显示JS值-6ren"> 中显示JS值-如何使用 document.write 从下拉菜单中显示值 document.write(rate)">Auto Insurance 这可能吗?我怎样才能实现这个目标?在下一页上,我需要 _GET“费-6ren">
gpt4 book ai didi

javascript - 如何在<选项值="url here & js here">中显示JS值

转载 作者:行者123 更新时间:2023-12-01 00:26:51 27 4
gpt4 key购买 nike

如何使用 document.write 从下拉菜单中显示值

<option value="jmp.php?type=auto&rate=<script>document.write(rate)</script>">Auto Insurance</option>

这可能吗?我怎样才能实现这个目标?在下一页上,我需要 _GET“费率”,但我不知道如何将其传递到值中。

提交表单时,此代码用于将用户发送到 value=""中的 URL

var goBtn = document.getElementById("search");
var menu = document.getElementById("s1");

goBtn.onclick = function() {
window.location = menu.value;
}

这是我正在使用的 HTML。

<script>
function getRate() {
var rate = document.getElementById("s2").value;
</script>
<div class="row">
<div class="col-md-12">
<div class="subscribe-block">
<div class="row">
<form class="form-horizontal" role="form" id="subscribeForm">
<div class="col-sm-4">
<fieldset style="margin-top: -1.1em">
<div style="color: #fff;">Insurance Plan</div>
<select id="s1" class="form-control input-lg">
<option value="jmp.php?type=auto&rate=<script>document.write(rate)</script>">Auto Insurance</option>
<option value="jmp.php?type=health&rate=<script>document.write(rate)</script>">Health Insurance</option>
</select>
</fieldset>
</div>
<div class="col-sm-4">
<fieldset style="margin-top: -1.1em">
<div style="color: #fff;">Estimated Current Payment</div>
<select name="s2" id="s2" class="form-control input-lg">
<option>$5</option>
<option>$10</option>
<option>$20</option>
<option>$30</option>
<option>$40</option>
<option>$50</option>
<option>$60</option>
<option>$70</option>
<option>$80</option>
<option>$90</option>
<option>$100</option>
<option>$110</option>
<option>$120+</option>
</select>
</fieldset>
</div>
<div class="col-sm-4">
<input style="color: #fff;" id="search" placeholder="Continue >>" class="btn btn-warning btn-block btn-lg">
</div>

最佳答案

<script>
var goBtn = document.getElementById("search");
var menu = document.getElementById("s1");
var myObject = {
"value1": "jmp.php?type=auto&rate=<script>document.write(rate)<\/script>",
"value2": "jmp.php?type=health&rate=<script>document.write(rate)<\/script>"
}
goBtn.onclick = function() {
window.location = myObject[menu.value];
}
</script>

<select id="s1" class="form-control input-lg">
<option value="value1">Auto Insurance</option>
<option value="value2">Health Insurance</option>
</select>

关于javascript - 如何在<选项值="url here & js here">中显示JS值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58906589/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com