tags:

views:

18

answers:

2

hello all..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 form 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
+1  A: 
$(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
A: 

@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(); 
});
Manie
it's not wrong really... you can just omit it though ;)
Reigel