Skip to main content
Participating Frequently
March 31, 2023
Question

Javascript for auto populate field based on checkboxes

  • March 31, 2023
  • 1 reply
  • 1064 views

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 has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
March 31, 2023

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

Participating Frequently
March 31, 2023

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.