开发者

how to show result at another form after click button?

开发者 https://www.devze.com 2023-01-09 19:26 出处:网络
i have two form. at form 1 there are: 1. one group of radiobutton <input id=\"def1\" type=\"radio\" class=\"defect\" name=\"defect\" value=\"S\"/>S

i have two form. at form 1 there are:

1. one group of radiobutton
    <input id="def1" type="radio" class="defect" name="defect" value="S"/>S
    <input id="def2" type="radio" class="defect" name="defect" value="A" />A
    <input id="def3" type="radio" class="defect" name="defect" value="B" />B
    <input id="def4" type="radio" class="defect" name="defect" value="C" />C

2. <button id="accept" value="accept">accept</button>
   <button id="reject" value="reject">reject</button>

at fo开发者_Python百科rm 2:

1. <input type="text" id="class">
2. <input type="text" id="status">

for example, if i choose A from radiobutton then click reject,at form 2 can show result:

at id="class" is A and at id="status" is reject


$(document).ready(function() {
    var selectedDefect;
    $('input[name="defect"]').click(function() {
        selectedDefect = $(this).val();
    });
    $('#accept').click(function() {
        $('#class').val(selectedDefect);
        $('#status').val('accept');
    });
    $('#reject').click(function() {
        $('#class').val(selectedDefect);
        $('#status').val('reject');
    });
});


@sabbour i think it's wrong to wrap the name with "",

instead of

$('input[name="defect"]').click(function() {
   selectedDefect = $(this).val(); 
});

should be

$('input[name=defect]').click(function() {
   selectedDefect = $(this).val(); 
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号