Reputation: 518
I use bootstrap 3 and a checkbox with a label. I managed to make the label tick off the checkbox when clicked, but the surrounding button design doesn't allow this feature.
<div class="btn btn-primary"><form action="link.php" method="post">
<label for="jevattend_id">This is the label</label>
<input type="checkbox" name="jevattend" id="jevattend_id" value="1" onclick="form.submit();"/>
</form></div>
To make that clear have a look at the jsfiddle: http://jsfiddle.net/etpq2/
I would like to tick off the box even when just the button is clicked.
Upvotes: 1
Views: 4884
Reputation: 28409
Put the label around what you want to have clicked to make the checkbox change state.
In this case just apply the button class to the label. The form doesn't belong inside the button.
<form action="link.php" method="post">
<label class="btn btn-primary">
This is the label
<input type="checkbox" name="jevattend" id="jevattend_id" value="1" onclick="form.submit();"/>
</label>
</form>
Upvotes: 2
Reputation: 8153
wrap your label around the input element, makes the whole area clickable, and its better for usability
Upvotes: -1