Skip to main content
January 12, 2022
Answered

Check box and text box

  • January 12, 2022
  • 1 reply
  • 490 views

Hi,

I am not an expert in JS that´s why I ask for help; I have a check box named "Check Box albac" and I pretend that when it is checked displays a code like "030342" in a text box named CODIGO NC. Easy, but too much for me.

Thanks in advance.

This topic has been closed for replies.
Correct answer ls_rbls

++EDITED REPLY

 

You may be able to achieve that with a Mouse-Up event script executed from the checkbox.

 

For example, you can assign "030342" as the export value of the checkbox, so when the user ticks the checkbox the "CODIGO NC" text field populates that value; un-ticking the check box will clear that value.

 

You can try and see if something like this works for you:

 

 

var cb = event.target;

if (cb.value == "Off") {

this.getField("CODIGO NC").value  = "";

} else {

this.getField("CODIGO NC").value  = cb.value;

} 

 

Alternatively, the single line of code below may be a concise and more elegant script (in my opinion) which executes  the same results:

 

this.getField("CODIGO NC").value = (event.target.value == "Off") ? "" : cb.value;

 

 

 

1 reply

ls_rbls
Community Expert
ls_rblsCommunity ExpertCorrect answer
Community Expert
January 12, 2022

++EDITED REPLY

 

You may be able to achieve that with a Mouse-Up event script executed from the checkbox.

 

For example, you can assign "030342" as the export value of the checkbox, so when the user ticks the checkbox the "CODIGO NC" text field populates that value; un-ticking the check box will clear that value.

 

You can try and see if something like this works for you:

 

 

var cb = event.target;

if (cb.value == "Off") {

this.getField("CODIGO NC").value  = "";

} else {

this.getField("CODIGO NC").value  = cb.value;

} 

 

Alternatively, the single line of code below may be a concise and more elegant script (in my opinion) which executes  the same results:

 

this.getField("CODIGO NC").value = (event.target.value == "Off") ? "" : cb.value;