Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Global event

Avatar

Level 4
On each field I have this script applied to the 'enter' and 'mouse enter' events: txtField.border.edge.color.value = "233,217,145";



To finish it off I have this script applied the 'exit' and 'mouse exit' events: txtRecordTitle.border.edge.color.value = "1,102,51";



All this does is simply highlight the active field using our corporate colours. It's function is mostly esthetic but it helps the user return to the active field if they are interrupted.



My question is -- is there a way to apply these scripts once so they apply globally? If I name all my fields txtField can I put some script at a page level that applies this? Or is this wishful thinking and I have to apply the script to every single field?
4 Replies

Avatar

Level 6
The script has to go on every field. I suggest you put the colours in form variables rather than hard coding them in the fields. I also suggest you use the custom object palette to reuse objects with these scripts.

Avatar

Level 4
Thanks Jared. I've never used variables so I'll have to do some more learning!<br /><br />I did have the objects in the custom object palette but it is necessary to change the field name in each of the 4 scripts for every field I add to a form. A major pain, and time consuming... and I'm always looking for a faster way of doing everything <grin>!

Avatar

Level 5
You could also use 'this' or '$' in place of field name based on your script language(JavaScript or FormCalc) preference. Using these will generalize the script and can be used from any field and greatly reduce your need to make changes in every event.



For example your code:

txtField.border.edge.color.value = "233,217,145";

will look like this.border.edge.color.value = "233,217,145"; if you use JavaScript.



Hope this helps...



Good luck,

SekharN

Avatar

Level 4
Thank you... thank you... thank you!!



Your script is SO much easier! I've already modified my custom objects accordingly.