Skip to main content
Participating Frequently
Mar 31, 2023 1:02 PM UTC
Question

Javascript for auto populate field based on checkboxes

I guess the title of the discussion is a bit misleading because I have already figured out how to fill out a text field based on the value entered on another text field if a certain box is checked, however: 

If the second checkbox is checked (var b2), I would like the user to be able to free text in that field. So essentially, I am asking how do I write Javascript for "Free Text" in an if statement. 

 

I tried not having a second variable at all, however, if the user accidentally selects the first checkbox, the value remains in the text field even if the checkbox is unchecked afterwards. 

 

var b1 = this.getField("RCB1").isBoxChecked(0);
var b2 = this.getField("RCB1").isBoxChecked(1);

if(b1)
event.value = this.getField("DLAST").value

if(b2)
event.value = (????????????????)

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

Nesa Nurani
Community Expert
Community Expert
Mar 31, 2023 3:48 PM UTC

You can use only condition for b1 or use script in checkbox.

Translate
Participating Frequently
Mar 31, 2023 3:54 PM UTC

What do you mean? 

I was able to condition for b1 and b2. For example, if I wanted b2 to autopopulate the fields based on other fields not stated in b1, I am successfully able to do so ... so I am unsure exactly how I can only condition for b1. Regardless, I am just trying to find how I can clear the fields via javascript and then allow the client to enter their own information. For now, I have conditioned the fields via Action tab to just reset the fields. 

Translate