<script language="javascript" type="text/javascript">
$('#leftDiv').ready(function(){
$("form").submit(function () {
//data structure
var radios = [];
//for printing purposes
var arrayValues = $("#arrayVal");
//Getting the values
$("form :radio:checked").each(function() {
radios = $(this).attr('value');
});
//Printing the values
$.each(radios, function( index, value ){
arrayValues.append(
$(value)
);
});
})
});
</script>
HTML “CODE”
<html>
<body>
<div id="leftDiv" class="container">
<form action="" method="get">
<fieldset>
<p>Something 0</p>
<lable>Yes</label>
<input type="radio" name="Group0" value="1" >
<lable>No</label>
<input type="radio" name="Group0" value="0" >
</fieldset>
<fieldset>
<p>Something 1</p>
<lable>Yes</label>
<input type="radio" name="Group1" value="1" >
<lable>No</label>
<input type="radio" name="Group1" value="0" >
</fieldset>
<fieldset>
<p>Something 2</p>
<lable>Yes</label>
<input type="radio" name="Group2" value="1" >
<lable>No</label>
<input type="radio" name="Group2" value="0" >
</fieldset>
<fieldset>
<input type="submit" name="update" class="button" value="Submit">
</fieldset>
</form>
</div>
</body>
</html>
Don’t know why but can only get the last value from the radio group.
What am I doing wrong?
Instead of
try