Skip to main content
Known Participant
August 29, 2018
Answered

Show/hide multiple fields if checkbox is activated

Hi,hopefully it is an easy one... when you click the checkbox, it allows you to fill the other fields...

many thanks!!

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
August 29, 2018

You can use something like this as the field's Mouse Up action:

var fields = ["Field1", "Field2", "Field3"];  // etc.

if (event.target.value=="Off") {

    this.resetForm(fields);

    for (var i in fields) this.getField(fields).readonly = true;

} else {

     for (var i in fields) this.getField(fields).readonly = false;

}

4 replies

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
August 29, 2018

You can use something like this as the field's Mouse Up action:

var fields = ["Field1", "Field2", "Field3"];  // etc.

if (event.target.value=="Off") {

    this.resetForm(fields);

    for (var i in fields) this.getField(fields).readonly = true;

} else {

     for (var i in fields) this.getField(fields).readonly = false;

}

Translate
Known Participant
August 30, 2018

Thanks

Is this correct? It is giving me an error "unterminated string literal 1: en linea 2"

var fields = ["Titular de la cuenta", "Iban", "Entidad", "Oficina", "DC", "Nº de cuenta];  // etc. 

if (event.target.value=="Off") { 

    this.resetForm(fields); 

    for (var i in fields) this.getField(fields).readonly = true; 

} else { 

     for (var i in fields) this.getField(fields).readonly = false; 

} 

Translate
try67
Community Expert
Community Expert
August 30, 2018

You're missing the closing double-quotes after "cuenta" at the end of the array definition...

Translate