Need help with a script

Avatar

Avatar
Validate 1
Level 3
jeanette614
Level 3

Likes

5 likes

Total Posts

129 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 3
jeanette614
Level 3

Likes

5 likes

Total Posts

129 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile
jeanette614
Level 3

19-05-2011

I am very inexperienced at scripting but I need a script to show a zero if a number goes negative.  So what I have is:

$.rawValue = X - Y

But I need rawValue to never show a negative number, only a zero when that value becomes a negative. Otherwise, show the value.

Please help.

Replies

Avatar

Avatar
Validate 1
Level 9
Srini_Dhulipall
Level 9

Likes

177 likes

Total Posts

1,397 posts

Correct reply

255 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 9
Srini_Dhulipall
Level 9

Likes

177 likes

Total Posts

1,397 posts

Correct reply

255 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
Srini_Dhulipall
Level 9

23-05-2011

You can use the following script to display ZERO instead of negative numbers.

var FinalValue = X-Y;


if(FinalValue<0) then
$.rawValue = 0;
else
$.rawValue = FinalValue;
endif

Thanks

Srini

Avatar

Avatar
Validate 1
Level 3
jeanette614
Level 3

Likes

5 likes

Total Posts

129 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 3
jeanette614
Level 3

Likes

5 likes

Total Posts

129 posts

Correct reply

1 solution
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Affirm 1
View profile
jeanette614
Level 3

23-05-2011

That seems like it should work but alas, it doesn't. Nothing shows in the field at all. Not even the negative numbers like I had before.

Avatar

Avatar
Validate 1
Level 9
Srini_Dhulipall
Level 9

Likes

177 likes

Total Posts

1,397 posts

Correct reply

255 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile

Avatar
Validate 1
Level 9
Srini_Dhulipall
Level 9

Likes

177 likes

Total Posts

1,397 posts

Correct reply

255 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 25
View profile
Srini_Dhulipall
Level 9

23-05-2011

Then the problem might be the language.. Set the scripting language to FormCalc instead of JavaScript in the Script editor. You can find it in the right had top corner in the Script editor.

Which event are you writing the code?

Thanks

Srini