I am trying to build a simple web page that dynamically creates a row of checkboxes. First, I figured out how to put the checkboxes in a single row:
.checkbox-inline {
display: inline-block;
}
<form role="form" method="post">
<legend>What is Your Favorite Pet?</legend>
<label class="checkbox-inline">
<input type="checkbox" name="cbpets[]" value="Cats">
Cats
<br>
</label>
<label class="checkbox-inline">
<input type="checkbox" name="cbpets[]" value="Dogs">
Dogs
<br>
</label>
</form>
Next, I found this page StackOverflow question (see first answer) and was able to create the checkboxes, but across multiple rows. Now I am stuck. I am trying to put the checkboxes in one row, but have not figured how. I tried adding (using the syntax in the stackoverflow answer)
var color = document.createElement("input");
color.setAttribute(
'style',
'class="checkbox-inline"',
);
But this didn’t work. Anything else you can suggest that I try?
<br>elements for?