How do I create checkboxes using Javascript? | XM Community
Skip to main content
Hi,



I am trying to customize a form question to include different types of inputs (i.e., drop down, multiselection). I have figured out to create a multiselection that requires ctrl to be held, but find it is not very user friendly. What I really would like is to do is have several checkboxes. Here is my currently code for the multiselection box. Can you help me adjust to checkboxes?



var element=' <select class="js-example-basic-multiple js-states form-control" id="id_label_multiple" multiple="multiple"><option value='Nobody'>Nobody</option><option value='Sibling'>Sibling</option><option value='Parent'>Parent</option><option value='Friend'>Friend</option></select>';

jQuery(element).insertAfter("#"+that+" .InputText:eq(3)");



jQuery("#s3").on('change',function(){

jQuery("#"+that+" .InputText:eq(2)").val(jQuery("#s3 option:selected").text());

});



Thanks,



Andrew
A checkbox is an input tag with a type of checkbox:

```

<input type="checkbox">

```

You would add it in JS the same way you added the select.

Leave a Reply