Expand my Community achievements bar.

SOLVED

Is it possible to script an image to open after another field reaches a certain value?

Avatar

Level 2

I have very little programming knowledge.  I was wondering if I had two calculations that would be compared with each other.  When the second total becomes equal to the first calculation, is it possible to have an image open?  (Such as flowers that say "Congratulations!") 

This is a stand alone form not connected to any data source.

Thanks,

Christina in Tucson

1 Accepted Solution

Avatar

Correct answer by
Level 10

poundsOn_Off.rawValue returns the value in String format which cannot be compared with a Number.

So use the following syntax to convert the String value to Number.

Nith

View solution in original post

7 Replies

Avatar

Level 10

1. Place an image field

2. Specify the Image URL and embed the image

3. Hide the image field

4. When you calculation succeeds, display the image field.

To show/hide an Image using script:

Nith

Avatar

Level 2

Dear Nith, Thank you so much. This is a great way to start the morning. I’ll try implementing it this morning – but I believe I see how this would work. This really improves the particular tool I’m working on. Again. Thank you.

Christina from Tucson

Avatar

Level 2

My tool is now almost ready for the image to pop up. I need help in changing the fontColor of the answer if the value is zero or negative. Is it javaScript, I presume.

The field name is: coloron_Offlbs

I want this to be red if it is greater than 0 and to be green if it is zero or less.

form1.Page1_InOut.colorOn_Offlbs::calculate - (JavaScript, client)

this.rawValue = poundsOn_Off.rawValue;

if (poundsOn_Off.rawValue > 0)

{

this.fontColor = "255,0,0";

}

if (poundsOn_Off.rawValue <= 0)

{

this.fontColor = "0,255,0";

}

I’ve tried many variations on this today but I can’t get the change to work. If I make the font red, once I got a green zero, but no other value.

Even without that fixed, I do not know how to script the image field. I named my test image the same as below and made it hidden – not invisible. Can you give me more details?

this.rawValue = poundsOn_Off.rawValue;

if (poundsOn_Off.rawValue > 0)

{

ImageField1.presence = "hidden";

}

if (poundsOn_Off.rawValue <= 0)

{

ImageField1.presence = "visible";

}

Thanks for your help.

Christina

Avatar

Level 2

This morning I succeeded in accomplishing what I wanted to do. Found another formula and changed it and then added your image presence fields. Thank you so much for helping out. Christina

Avatar

Level 2

Well - my eyes were not awake - just happy with some success.  With the below script I get the image on and off but I have lost the colored value - I only get a zero either green or red - not the value of the poundsOn_Off.rawValue.  Does there need to be some other operative to get the two actions - I have tried using a seperate field to hide/show the image - but that is not working either.  Thanks.  Christina

The scripting is now:

this.fillColor = "255,255,255";

this.rawValue = "";

if (poundsOn_Off.rawValue >1 && poundsOn_Off.rawValue <1000)

{

this.fillColor = "255,255,255";

this.fontColor ' "255,0,0";

this.rawValue ' poundsOn_Off.rawValue:

ImageField1.presence ' "hidden";

}

if (poundsOn_Off.rawValue <1)

{

this.fillColor = "255,255,255";

this.fontColor ' "0,255,0";

this.rawValue ' poundsOn_Off.rawValue:

ImageField1.presence ' "visible";

 

Avatar

Correct answer by
Level 10

poundsOn_Off.rawValue returns the value in String format which cannot be compared with a Number.

So use the following syntax to convert the String value to Number.

Nith

Avatar

Level 2

Nith, This has really helped – on this issue and another. Thanks. Christina