Expand my Community achievements bar.

Return text fields to default format (borders and fill color)

Avatar

Former Community Member

Hello,

I have several text fields that become highlighted or have borders drawn around them based on selections a user makes from a set of radio buttons.  I would like the formatting of the text boxes to return to the default (no border and no fill) when different radio buttons are selected.

More specifically, this is for a Personnel Status Change form, with the options "New Employee" (radio button 1), "Change to Existing Employee" (button 2), and "Separating Employee" (button 3).  Below the radio buttons are several text boxes where the user can enter relevent info.  When radio button 1 is selected the required fields for that option become highlighted or have borders drawn around them.  When button 2 is selected a different set of text boxes become highlighted -- however the first set of text boxes are still highlighted.  I would like the first set of text boxes to drop the highlighting when button 2 is selected.

I am using JavaScript set to run on the client side in a Dynamic PDF built in LiveCycle Designer 8.05.  Any help is much appreciated.  A sample of my code is below.

Also, I did think of adding text boxes that sit on top of the other text boxes, and making them visible and highlighted only when the corresponding radio button is selected.  I would prefer not to use that work around if possible.

Thanks!

Mike

------------------------------

sample code:

if (this.rawValue == 1) {
ddl_Add.presence = "visible";
ddl_ChgJob.presence    = "invisible";
ddl_Sep.presence = "invisible";
txt_green.border.edge.color.value = "0,255,0";
txt_red.fillColor = "255,0,0";
}
else if (this.rawValue == 2){
ddl_Add.presence = "invisible";
ddl_ChgJob.presence = "visible";
ddl_Sep.presence = "invisible";
txt_green.border.edge.color.value = ** THIS IS WHERE THE ISSUE IS **;
txt_red.fillColor = ** THIS IS WHERE THE ISSUE IS **;
}
else if (this.rawValue == 3) {
ddl_Add.presence = "invisible";
ddl_ChgJob.presence = "invisible";
ddl_Sep.presence = "visible";
txt_green.border.edge.color.value = ** THIS IS WHERE THE ISSUE IS **;
txt_red.fillColor = ** THIS IS WHERE THE ISSUE IS **;
}
else {
ddl_Add.Presence = "visible";
ddl_ChgJob.presence = "visible";
ddl_Sep.presence = "visible";
txt_green.border.edge.color.value = ** THIS IS WHERE THE ISSUE IS **;
txt_red.fillColor = ** THIS IS WHERE THE ISSUE IS **;
}

6 Replies

Avatar

Level 10

Hi Mike,

Here is a sample where the visual appearance of objects is changed. The script is in the enter/exit and prePrint/postPrint events, but could be copied to the radio buttons.

Good luck,

Niall

Avatar

Former Community Member

Dear Niall,

Thanks for the assistance, after some experimenting I was able to replicate your results!  I inserted your code just before the </field> for an individual radio button and in the PDF preview was able to put an orange border around a text field by clicking on the radio button.  When I clicked on another radio button the text field reverted back to its original format.  So, that is the functionality I wanted.

I do have a follow up question though.  It looks like your code creates variables and runs loops for the 'enter' and 'exit' activities for each text field to control that text field's formatting.  My form will eventually have about 50 text fields whose appearances will change based on which radio button is selected, so that would be a lot of coding.  Is there a shorter way to achieve these results?

I really appreciate your help and your solution is definitely workable, I was just hoping there was a simple piece of code that could 'revert' a text field's formatting back to its original format.

Thanks,

Mike

Avatar

Level 10

Hi,

I am out of the office at the moment; however you should try and avoid inputting script in the XML Source tab. There is a Script Editor window at the top of the screen. If it is a single line you can drag it down to make it bigger:

Parallels Desktop1.png

If you can't see it then you can select it from the Windows menu or pressing Shift + F5.

Copying script diectly into the XML Source may lead to troubles.

Once you have the script editor open, it is easier to see how the script is working and which event it is in.

You can set up a function to change the visual appearance and then each field refers to the function. This way you only have to maintain the function. I will try and post a sample later, when I get back.

Good luck,

Niall

Avatar

Level 10

Sorry, I am back in the office now, so I can catch up with this.

I may have been mistaken that you inserted the script into the XML Source tab - sorry. Looking again at your original post, it looks like you had been using the script editor after all.

Here is a sample, where the script for changing the visual appearance is in a function (see the script object in the Variables root). Each object then calls the function as necessary.

If you wanted to change the visual appearance of the objects in one hit, then it may be possible to amend Paul Guerette's example of LockAllFields function to loop through a complete form and change each object as it goes.

Good luck,

Niall

Avatar

Former Community Member

Thanks for getting back to me again.  My understanding now is that there is no simple line of code to revert a text field's format back to its default format.  Therefore, the best way to change a text field's format and then revert it back is through the loop functions that you provided.  If my understanding is correct then you have answered my question.

I will try using the new approach that you provided.

Thanks,

Mike

Avatar

Level 10

Yes Mike , that is how we are doing it. One event uses a function (like the enter event calling the getsFocus function) then a different event will use a separate function (like the exit event calling the loseFocus function). The defined colours in the loseFocus function are the same as the default object colours. 

I don't think there is a single magic line of script. A reset command will reset data as well - so isn't much good.

Good luck,

Niall