This topic is locked

check box field selection

4/13/2011 4:22:09 PM
PHPRunner General questions
S
salim author

How can I enable / disable fields in view/add page based on check box selection.
I have three fields, fl1 - check box, fl2 - date, fl3 - drop down. If fl1 is unchecked fl2 & fl3 should be disabled, if checked then both fl2 & fl3 should be enabled.
Thanks

Sergey Kornilov admin 4/13/2011

Check this article for inspiration:

http://xlinesoft.com/phprunner/docs/show_dropdown_list_of_us_states.htm
Instead of showing and hiding controls you can use setEnabled()/setDisabled() functions.
More info:

http://xlinesoft.com/phprunner/docs/javascript_api.htm

S
salim author 4/14/2011



Check this article for inspiration:

http://xlinesoft.com/phprunner/docs/show_dropdown_list_of_us_states.htm
Instead of showing and hiding controls you can use setEnabled()/setDisabled() functions.
More info:

http://xlinesoft.com/phprunner/docs/javascript_api.htm


Thanks for you reply, I have done exactly what the drop down list us states suggested. When I check the check box, the other field do get disabled, but when I uncheck it the field does not get enabled. The code is appended below, please help me out. Thanks
var ctrldr_1 = Runner.getControl(pageid, 'dr_1');

var ctrlSRDate1 = Runner.getControl(pageid, 'SRDate1');
ctrldr_1.on('checked', function(e){
if (this.getValue() == 1){

ctrlSRDate1.setEnabled();

}

else{

ctrlSRDate1.setDisabled();

}

J
Jane 4/14/2011

I suppose you need to use onchange event instead:

ctrldr_1.on('change', function(e){