由分部检测的单选按钮选择

时间:2014-03-22 19:24:26

标签: html

假设我有两个单选按钮

    <input id="Individual User" type="radio" name="register_form_categories" value="Individual User" />
    <label for="Individual User">Individual User</label>

    <input id="Group Admin" type="radio" name="register_form_categories" value="Group Admin" />
    <label for="Group Admin">Group Admin</label>

现在我还有一个Next divison

<a href="#"><div class="sign_in_me">Next</div></a>

如何打开不同的servlet,让individual.html和group.html点击不同的单选按钮,然后单击下一步。

请帮忙

1 个答案:

答案 0 :(得分:0)

您可以使用以下内容 http://jsfiddle.net/Hz3LZ/

$(docukment).ready(function(){
    if( $("input[name='register_form_categories']:checked")){
      changeLink($("input[name='register_form_categories']:checked").val());
     }
    $('input[type="radio"]').change(function(){
      changeLink($(this).val());
    })

 })

function changeLink(value){
var arr =value.split(' ');
//the above will take the value of the checked radio
//and split it on space. This will give you an array that contains 2 strings.
//If you check Group Admin, then you have arr[0]='Group' and arr[1]='Admin'
   $('#a-next').attr('href',arr[0].toLowerCase()+'.html');
}