This topic is locked
[SOLVED]

 Checkbox with javascript clear value

3/1/2020 3:13:51 PM
PHPRunner General questions
B
beishmc author

Hello, I need help with settings on the edit page JavaScriptOnLoad event.
I've got text field phone number and want to be shown only when boolean field checkbox (phone number enabled) is checked so users can enter a phone number if mark the checkbox on.
I've found a solution for this part of the problem but what I need now is when the user unchecks the checkbox to clear previously entered phone number from field phone number so that number is not saved into the database.

woodey2002 3/1/2020

Try this,

var ctrlIvc50 = Runner.getControl(pageid, 'checkboxname');

var ctrlIvc50T = Runner.getControl(pageid, 'phonenumber');
ctrlIvc50.on('change', function(e) {

if (this.getValue()=='on'){

pageObj.showField("phonenumber");

ctrlIvc50T.addValidation("IsRequired");

}

else {

pageObj.hideField("phonenumber");

ctrlIvc50T.removeValidation("IsRequired");

ctrlIvc50T.setValue('');

ctrlIvc50T.clear();

}

});
if(ctrlIvc50.getValue()!="on")

pageObj.hideField("interventionCode50Total");

ctrlIvc50T.clear();
B
beishmc author 3/2/2020



Try this,

var ctrlIvc50 = Runner.getControl(pageid, 'checkboxname');

var ctrlIvc50T = Runner.getControl(pageid, 'phonenumber');
ctrlIvc50.on('change', function(e) {

if (this.getValue()=='on'){

pageObj.showField("phonenumber");

ctrlIvc50T.addValidation("IsRequired");

}

else {

pageObj.hideField("phonenumber");

ctrlIvc50T.removeValidation("IsRequired");

ctrlIvc50T.setValue('');

ctrlIvc50T.clear();

}

});
if(ctrlIvc50.getValue()!="on")

pageObj.hideField("interventionCode50Total");

ctrlIvc50T.clear();



Thank you for your answer, i've tried this code and it's not working, hiding field works but unsetting values not, still leaves values in the database.

woodey2002 3/2/2020

Hi add a similar event to the edit page before record updated event!



if($values["ffd_Question"] !="Yes")

{

$values["ffd_Date"] ="";

$values["ninty_Day_Ffd_Breech"] ="";

$values["total_Days_Ffd"] ="";

}
B
beishmc author 3/2/2020



Hi add a similar event to the edit page before record updated event!



if($values["ffd_Question"] !="Yes")

{

$values["ffd_Date"] ="";

$values["ninty_Day_Ffd_Breech"] ="";

$values["total_Days_Ffd"] ="";

}



It works now, thank you very much.

Best forum members ever, so helpful.
Thank you again.