Skip to content

Instantly share code, notes, and snippets.

@bkamapantula
Created January 31, 2013 21:15
Show Gist options
  • Save bkamapantula/4686523 to your computer and use it in GitHub Desktop.
Save bkamapantula/4686523 to your computer and use it in GitHub Desktop.
Creating radio buttons on the fly
<script>
$(document).ready(function(event) {
var data = <?php echo json_encode($uploadedData);?>;
for (var j=0; j<data.length; j++) {
if(j == 0) {
$('<input >', {type: 'radio', value: data[j]['type'], name: "radioButtons", checked: true }).appendTo('#target');
}
else {
$('<input >', {type: 'radio', value: data[j]['type'], name: "radioButtons" }).appendTo('#target');
}
$('#target').append('<label for="' + data[j]['type'] + '">'+ data[j]['type'] + '</label><br />');
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment