I have a simple form with several bootstrap toggle checkboxes like so:
<input type="checkbox" value="8" name="fee_hidden8" id="fee_hidden8" class="btoggle" data-toggle="toggle" data-on="<i class='glyphicons glyphicons-eye-close'></i> Hidden" data-off="<i class='glyphicons glyphicons-eye-open'></i> Visible" data-onstyle="danger" data-offstyle="success">
<input type="checkbox" value="9" name="fee_hidden9" id="fee_hidden9" class="btoggle" data-toggle="toggle" data-on="<i class='glyphicons glyphicons-eye-close'></i> Hidden" data-off="<i class='glyphicons glyphicons-eye-open'></i> Visible" data-onstyle="danger" data-offstyle="success">
Where the 'id' of the record to be updated is the 'value' of the checkbox.
I want to pass the "value" of the checkbox to my jquery function -- or -- grab the assigned value that contains the id of the record to update:
$(function() {
$('.btoggle').change(function() {
if($(this).prop('checked'))
{var st = 'Yes'}
else
{var st = 'No'};
// not sure what to do here
//var fx = $(this).val();
var fx = $(this).attr('value');
alert(fx);
$.post("tsafunctions.cfc", {
method: 'visiblehidden',
fc: fx,
status: st
});
})
});
Aucun commentaire:
Enregistrer un commentaire