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();
});
精彩评论