Expand my Community achievements bar.

make a subform a read only

Avatar

Level 2

Hi all,

I'm new to scripting, a sample code will help.

I have a form with three subforms in it. One subform (subform1) contains radio buttons, radiobutton1 & radiobutton2. When radiobutton1 is selected, I need to disable subform 2 and all its elements. Same thing when selected radiobutton2, subform3 and all its elements are disabled.

How do I do this?

Any response is helpful.

Thanks.

J.

6 Replies

Avatar

Former Community Member

The radio buttons will be part of a RadioButton group. On the change event of that group you will add your code there. If you query the group object it wil return the value of the button that is selected. So if you have one button for Yes and one button for  No (and you have set them up to return those values, then you can use code something like this:

if (this.rawValue == "Yes"){

   subform2.presence = "hidden";

} else {

   subform2.presence = "visible";

}

You can also set the presence to invisible and the subform space will still be there (blank of course). Hidden will exclude the subform from the layout and if the form is created properly will reflow so there is no blank space. Make sure to save your form as a dynamic form.

Paul

Avatar

Level 2

Thanks Paul.

With  your script, it hides the subforms with a selection of a radiobutton.

I don't want the subforms to be invisible. I need to just disable the elements in the subform.

I tried your code that you have sent me by I can't figure it out (dumb to scripting, especially the "for loop").

Thanks.

Avatar

Former Community Member

The code is set up to accept a subform and will lock everything in that subform. So you shoudl be able to make a call to the scriptobject and pass the subform name (complete path) that you want to lock so something like this (your path will be different). The original command looked like this:

myScriptObject.LockAllFields(form1);

Modify to look like this:

myScriptObject.LockAllFields(form1.Page1.subformName);

Make sense?

Paul

Avatar

Level 7

Paul - Can you please send me that code....

Aditya