我有一些非常简单的表单,可以根据用户选择的无线电选项将用户发送到特定的网页。我认为这些会将值附加到某种变量上,类似于jquery可以读取并转发到我们指定的网页上。
<form id="weight-loss">
<input type="radio" id="form1_option1" name="weight-loss" value="5_day" class="plan" /><label for="form1_option1"> 5 Day - All Inclusive Price</label><br />
<input type="radio" id="form1_option2" name="weight-loss" value="7_day" /><label for="form1_option2"> 7 Day - All Inclusive Price</label><br />
<input type="submit" value="Place Order" alt="Submit button" class="orange_btn" />
</form>
我似乎无法在网络上找到任何真正有用的东西。谢谢你的帮助。
答案 0 :(得分:2)
演示:http://www.jsfiddle.net/pRhjq/
<script type="text/javascript">
function choosePage() {
if(document.getElementById('weightloss').form1_option1.checked) {
window.location.replace( "http://google.com/" );
}
if(document.getElementById('weightloss').form1_option2.checked) {
window.location.replace( "http://yahoo.com/" );
}
}
</script>
<form id="weightloss">
<input type="radio" id="form1_option1" name="weight-loss" value="5_day" class="plan">
<label for="form1_option1"> 5 Day - All Inclusive Price</label><br>
<input type="radio" id="form1_option2" name="weight-loss" value="7_day">
<label for="form1_option2"> 7 Day - All Inclusive Price</label><br>
<input type="button" value="Place Order" alt="Submit button" class="orange_btn" onclick="choosePage()">
</form>
答案 1 :(得分:0)
使用此:http://www.techiegyan.com/2008/07/09/using-jquery-check-boxes-and-radio-buttons/
与此相结合:window.location.href ='new_location.htm';
答案 2 :(得分:-1)
最简单的说,你可以让表单的方法成为GET:
<form id="weight-loss" method="get" action="some_page.php">
<input type="radio" id="form1_option1" name="weight-loss" value="5_day" class="plan" /><label for="form1_option1"> 5 Day - All Inclusive Price</label><br />
<input type="radio" id="form1_option2" name="weight-loss" value="7_day" /><label for="form1_option2"> 7 Day - All Inclusive Price</label><br />
<input type="submit" value="Place Order" alt="Submit button" class="orange_btn" />
</form>
然后你可以让some_page.php根据其减肥变量的值显示不同的页面。或者,至少,它可以根据该变量重定向。