Newbie needs help!!
I am trying to write a script to check a box, but only after a numeric field adds up to "4"
If you look at my attached file, "Student 1" has four check boxes (Pre-Course Skills, course roster, etc.). Each time those boxes are checked/unchecked, the numeric field + or - 1 from the rawValue. The script that I'm having problems with is on the check box next to Student 1 ...
Here's the "calculate" script attached to that check box:
if (stu1_results.rawValue == 4) {
CheckBox_stu1.rawValue == true; // Check the box
else {
CheckBox_stu1.rawValue == false; // Un-check the box
}
Any advice would be awesome!!
Mike Schaefer
(blinkyguy)
Solved! Go to Solution.
There were two things wrong with your code. Logically it was fine but you were mixing up an assign,ent statement and a comparison. In an if statement if you wantt o compare two values you need two equal signs. If you want to assign one value to another you need a single equal sign. That was number one. NUmber two is when you assign the value of the checkbox. The on/off values are 1/0 not true/false. So you can either modify your code to assign a 1/0 value instead of true/false or modfiy the checkbox to have true/false as its values instead of 1/0.
The code shoudl look like this:
if (stu1_results.rawValue == 4){
CheckBox_stu1.rawValue =1;
} else {
CheckBox_stu1.rawValue = 0;
}
Paul
Views
Replies
Total Likes
Try:
if (stu1_results.rawValue == 4) {
CheckBox_stu1.rawValue = true; // Check the box
else {
CheckBox_stu1.rawValue = false; // Un-check the box
}
Views
Replies
Total Likes
Unfortunately, the suggestion did not work ...
I believe your example was missing a " { " ... here's what I tried and still a no-go:
if (stu1_results.rawValue == 4) {
CheckBox_stu1.rawValue = true; // Check box
}
else {
CheckBox_stu1.rawValue = false; // Un-check box
}
Thanks,
Mike S.
Views
Replies
Total Likes
I now have it working by doing the following:
1 - Changed from "JavaScript" to "FormCalc" language
2 - Changed the script to look like:
if (stu1_results.rawValue == 4) then
CheckBox_stu1.rawValue = 1; // Check box
else
CheckBox_stu1.rawValue = 0; // Un-Check box
endif
For anyone out there, I would love it if someone could tell me how to properly script the above in JavaScript, as that is what I am more familiar with.
Thanks,
Mike S.
Views
Replies
Total Likes
There were two things wrong with your code. Logically it was fine but you were mixing up an assign,ent statement and a comparison. In an if statement if you wantt o compare two values you need two equal signs. If you want to assign one value to another you need a single equal sign. That was number one. NUmber two is when you assign the value of the checkbox. The on/off values are 1/0 not true/false. So you can either modify your code to assign a 1/0 value instead of true/false or modfiy the checkbox to have true/false as its values instead of 1/0.
The code shoudl look like this:
if (stu1_results.rawValue == 4){
CheckBox_stu1.rawValue =1;
} else {
CheckBox_stu1.rawValue = 0;
}
Paul
Views
Replies
Total Likes
Thank you all for your help. Tried out the JavaScript and it worked like a charm!
Always the best source for help!!
Mike S.
Views
Replies
Total Likes
Hi Paul,
I'm having a similar problem but your suggestion didn't work for me, at least not right away. I had to click around on the form to make the check box tic. Basically, I used:
if (JhammerSatTotal.rawValue <=80){
JhammerPassed.rawValue =1;
} else {
JhammerPassed.rawValue =0;
}
Essentially I have two boxes: one if they passed and one if they failed. So, if the value of the points awarded is greater than or equal to 80, then the 'passed' box tics. I added the less than version to the 'failed' box. They only seem to tic if I click on the JhammerSatTotal cell, then away, then back again. Is this just a quirk of the program or is there a way for it to be more responsive?
Thanks!
~Laura
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies