I have some very simple forms that will send the user to a specific webpage based on their selected radio option. I figured these would append the value to some sort of variable that something like jquery could read and forward onto the w开发者_如何学运维ebpage we specify.
<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>
I can't seem to find anything that really helps in this regard on the web. Thanks for all your help.
Demo: 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>
Use this: http://www.techiegyan.com/2008/07/09/using-jquery-check-boxes-and-radio-buttons/
In combo with this: window.location.href = 'new_location.htm';
At the simplest, you could make the form's method a 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>
Then you can have some_page.php display different pages based on the value of its weight-loss variable. Or, at the very least, it could redirect based on that variable.
精彩评论