I'm having a problem with jQuery checkbox manipulation. I have several fieldsets with checkboxes, and I want that when the person clicks on a check the check value is added to the input hidden of each fieldset.
I wanted to know how I get this value from the check that was clicked.
var text1 = document.getElementById("text1");
var text = document.getElementById("text2");
$("#radios1 .check").click(function () {
text1.value = $(this).val();
$(this).attr("checked");
alert(text1.value);
});
<fieldset id="radios1">
<input class="check" type="checkbox" value="1"> <br />
<input class="check" type="checkbox" value="2">
<input type="hidden" id="text1" value="1" />
</fieldset>
<fieldset id="radios2">
<input class="check" type="checkbox" value="1"> <br />
<input class="check" type="checkbox" value="2">
<input type="hidden" id="text2" value="1" />
</fieldset>
I made a JSFIDDLE with what I have so far: link
Does anyone know how to proceed?