Hallo,
Ik ben aan het proberen om mooie bootstrap buttons te gebruiken voor checkboxen en radioboxen via button.js http://getbootstrap.com/javascript/#buttons. Ze worden nu ook netjes getoond. Nu is echter de vraag hoe ik de checked-status van de knoppen koppel aan een php variabele.
Bv variabele $switchstatus = on dat dan de actieve state van die knop ook zo staat. Voor php is dit uiteraard mogelijk met de checked optie in de input zetten. Nu nog de jquery kant
Vb
<?php $switchstatus = "on"; ?>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" name="options" value="on" <?php if $switchstatus == "on" { echo 'checked=checked';} ?>> On
</label>
<label class="btn btn-primary">
<input type="radio" name="options" value="off" <?php if $switchstatus == "off" { echo 'checked=checked'} ?>> Off
</label>
</div>
Ik ben aan het proberen om mooie bootstrap buttons te gebruiken voor checkboxen en radioboxen via button.js http://getbootstrap.com/javascript/#buttons. Ze worden nu ook netjes getoond. Nu is echter de vraag hoe ik de checked-status van de knoppen koppel aan een php variabele.
Bv variabele $switchstatus = on dat dan de actieve state van die knop ook zo staat. Voor php is dit uiteraard mogelijk met de checked optie in de input zetten. Nu nog de jquery kant
Vb
<?php $switchstatus = "on"; ?>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary">
<input type="radio" name="options" value="on" <?php if $switchstatus == "on" { echo 'checked=checked';} ?>> On
</label>
<label class="btn btn-primary">
<input type="radio" name="options" value="off" <?php if $switchstatus == "off" { echo 'checked=checked'} ?>> Off
</label>
</div>
[ Voor 8% gewijzigd door Thuurke op 30-11-2013 10:46 ]