Skip to main content
johnnyZ
Inspiring
February 27, 2024
Answered

Clear field data dependent on checkbox YES or NO

  • February 27, 2024
  • 1 reply
  • 514 views

I have a question on a form with 2 checkboxes  (YES or NO)

Depending upon the checkbox, I would like a script that will clear all the data in 3 specific fields.

If YES is checked, the focus moves to the next field. (This already works)

If NO is checked, clear all data in the 3 fields. (This is what I'm looking for.)

This topic has been closed for replies.
Correct answer Nesa Nurani

Use as 'Mouse UP' action of 'NO' checkbox and replace field names with your actual filed names:

if(event.target.isBoxChecked(0)){
this.getField("Field1").value = "";
this.getField("Field2").value = "";
this.getField("Field3").value = "";}

1 reply

Nesa Nurani
Nesa NuraniCorrect answer
Community Expert
February 27, 2024

Use as 'Mouse UP' action of 'NO' checkbox and replace field names with your actual filed names:

if(event.target.isBoxChecked(0)){
this.getField("Field1").value = "";
this.getField("Field2").value = "";
this.getField("Field3").value = "";}

johnnyZ
johnnyZAuthor
Inspiring
February 27, 2024

Thanks again Nesa.

I modified your suggestion to:

if (event.target.value == "NO") {
this.getField("Tobacco_Packs_per_day").value = "";
this.getField("Tobacco_years_usage").value = "";
this.getField("Tobacco_Quit_Date").value = "";}