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.

Calculate directly in a field like you can in Excel

Avatar

Level 4

Is it possible to type a calculation into a field and once you exit the field it will display the result?  For example, type 30+40 and then exit the field and it will display 70.

8 Replies

Avatar

Level 10

There's nothing built-in to do that but you might be able to write script to handle it.

Avatar

Level 8

In the exit event of the field, language=JavaScript put:

this.rawValue=eval(this.rawValue);

Kyle

Avatar

Level 10

Oh sure Kyle make it look easy...

Avatar

Level 4

Thanks for the response.  I got it to work in a Text Field, but not a Numeric Field. How can it to work in a Numeric Field that has a pattern or is this not possible?

Avatar

Level 4

I have a few, but the main one is the first one listed below.

num{($zzz,zzz,zz9)}

num{zzzz9.zz}

num{zz9.9%}

num{zzzzz.9%}

Avatar

Level 8

Technically, you CAN use those patterns for text fields although it's not officially supported. Make sure the parentheses on your first one are taken out and put single quotes (') around your percentage sign.

Kyle

Avatar

Level 4

Thanks so much for your help!