Expand my Community achievements bar.

If Else Syntax Help

Avatar

Level 2
I need some help with my javascript syntax. I am trying to populate a numeric field based on a check box. This is what I am trying to use:



if(this.rawValue==1)

{form1.subForm1.numericField1="5";}

else

{form1.subForm1.numericField1="10";}



So, if the box is checked the text field should be populated with the number 5, if not then it should have a number 10.



If formCalc is easier to use, please let me know how because I didn't have any luck there either.



Any help would be greatly appreciated.
2 Replies

Avatar

Level 10
You missed the "rawValue" and you don't need quotes around the value.



>if (this.rawValue == 1)



form1.subForm1.numericField1.rawValue = 5;



else



form1.subForm1.numericField1.rawValue = 10;



(You don't need the {} if there's only one statement.)



And if you want the field to be populated already add

>this.rawValue = 10;



to the "initialize" event of "numericField1"