This topic is locked

Calculating values on the fly

6/28/2011 7:18:15 AM
PHPRunner General questions
J
jackaroo author

How should I modify the "values on the fly" example in the documentation to incorporate a series of checkboxes.

I am successful in manipulating the checkbox value(s) selected, but I cannot figure out how to specify the checkboxes with 'keyup' events.
Thanks,

Jack

C
cgphp 6/28/2011

Jack333,
you have to use click event not keyup.

var ctrl = Runner.getControl(pageid, 'your_checkbox_field_name');
function func()

{

var checkbox_status = $("input[name='your_checkbox_field_name']").is(':checked');
if(checkbox_status)

{

//checkbox is enabled

}

else

{

//checkbox is disabled

}

}
ctrl.on('click', func);


or a more compact solution:

$("input[name='your_checkbox_field_name']").click(function(e) {

if($(this).is(':checked'))

{

//checkbox is enabled

}

else

{

//checkbox is disabled

}

});
J
jackaroo author 6/28/2011



Jack333,
you have to use click event not keyup.

var ctrl = Runner.getControl(pageid, 'your_checkbox_field_name');
function func()

{

var checkbox_status = $("input[name='your_checkbox_field_name']").is(':checked');
if(checkbox_status)

{

//checkbox is enabled

}

else

{

//checkbox is disabled

}

}
ctrl.on('click', func);


or a more compact solution:

$("input[name='your_checkbox_field_name']").click(function(e) {

if($(this).is(':checked'))

{

//checkbox is enabled

}

else

{

//checkbox is disabled

}

});



Thanks for your help. I have a group of checkboxes for the same field_name. How do I differentiate between them?

C
cgphp 6/28/2011

Put square brackets after the input name:

$("input[name='your_checkbox_field_name[]']").click(function(e) {

if($(this).is(':checked'))

{

alert($(this).val());

}

else

{

//checkbox is disabled

}

});