Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Check box value assigned by Numeric Field rawValue

Avatar

Level 1

This was asked and answered back in 2009 (http://forums.adobe.com/message/5944725#5944725), but I have a twist to the question:

I'm able to get the action to work, but not right away. I had to click around on the form to make the check box tic. I assigned the following code to the JhammerPassed-named check box:

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

1 Accepted Solution

Avatar

Correct answer by
Level 7

Typos... And possibly copy/paste didn't keep that first line together...

var tempValue = form1.Page4.JhammerTest.Row1.JhammerSat1 + form1.Page4.JhammerTest.Row1.JhammerSat2 + form1.Page4.JhammerTest.Row1.JhammerSat3+ form1.Page4.JhammerTest.Row1.JhammerSat4;

should be

var tempValue = parseInt(form1.Page4.JhammerTest.Row1.JhammerSat1.rawValue) + parseInt(form1.Page4.JhammerTest.Row2.JhammerSat2.rawValue) + parseInt(form1.Page4.JhammerTest.Row3.JhammerSat3.rawValue) + parseInt(form1.Page4.JhammerTest.Row4.JhammerSat4.rawValue);

Message was edited by: jasotastic81 after a couple of typos and fixing a logic problem, this should be right.

View solution in original post

0 Replies

Avatar

Level 10

What event do you have the code on? For it to check the value of the other field it should probably be on the Calculate event.

I would reverse the script and put it on the Exit event of the "JhammerPassed" field (unless that is a calculated total).

Avatar

Level 1

Thanks for your response. The JhammerSatTotal is the calculated field (in a table) and the JhammerPassed is the check box that needs to be ticked if JhammerSatTotal is <= 80. I'm not fabulous with Javascript, so if you suggest the Calcualate option, can you help with the code?

Avatar

Level 7

I don't know how many rows you are adding values from, but this worked as a test with two items in the "calculate" event for JhammerSatTotal.

tfPartA.rawValue + tfPartB.rawValue >= 80 ? JhammerPassed.rawValue = 1 : JhammerPassed.rawValue = 0;

this.rawValue = parseInt(tfPartA.rawValue) + parseInt(tfPartB.rawValue);

Something like this would work, too.

var tempValue = parseInt(tfPartA.rawValue) + parseInt(tfPartB.rawValue);

tempValue >= 80 ? JhammerPassed.rawValue = 1 : JhammerPassed.rawValue = 0;

this.rawValue = tempValue;

If you have a lot of rows in your table (especially if the table is dynamic), then using a for loop to add them up first might be better.

Avatar

Level 1

I'm adding up 4 rows into JhammerSatTotal. The script I have in JhammerSatTotal is:

Sum(form1.Page4.JhammerTest.Row1.JhammerSat1

,form1.Page4.JhammerTest.Row2.JhammerSat2,form1.Page4.JhammerTest.Row3.JhammerSat3,

form1.Page4.JhammerTest.Row4.JhammerSat4)

(I tried simpler code, but this was the only one that worked.) So, the 4 fields that the total field is adding up are: JhammerSat1, JhammerSat2, JhammerSat3, JhammerSat4. These 4 fields are user entered.

Basically, my table looks as follows:

StepsPointsSatUnsat
Step 110
Step 240
Step 310
Step 440
Total:100

Then, there are two check boxes under the table: Passed and Failed. The user enters points into the Sat and Unsat rows while the total row is added up. If the total in the Sat column is <= 80, the Passed box should be checked. And the Failed box if it's >80.

Would this make a difference with your suggestion above?

Avatar

Level 7

OK, based on your description, I would have the calculate event for your JhammerSetTotal look like this:

var tempValue = form1.Page4.JhammerTest.Row1.JhammerSat1 + form1.Page4.JhammerTest.Row1.JhammerSat2 + form1.Page4.JhammerTest.Row1.JhammerSat3 + form1.Page4.JhammerTest.Row1.JhammerSat4;

if (tempValue <= 80) {

     JhammerPassed.rawValue = 1;

     JhammerFailed.rawValue = 0;

}

else {

     JhammerPassed.rawValue = 0;

     JhammerFailed.rawValue = 1;

}

this.rawValue = tempValue;

Avatar

Level 1

One more quick question, though. Do I need to change the text field value? I had it set to 'Calculated - Read Only' and JhammerSatTotal is no longer displaying the total of the Sat rows. I just want to make sure I'm not doing something stupid.

Avatar

Level 7

Is that happening after changing your script to what I posted above?

Your setting is correct. You don't want a user modifying that value since it's calculated from other fields.

Avatar

Level 1

Yes, I change my javascript to what you sent and JhammerSatTotal field no longer calcuates. The Script field is set to Javascript language.

Avatar

Correct answer by
Level 7

Typos... And possibly copy/paste didn't keep that first line together...

var tempValue = form1.Page4.JhammerTest.Row1.JhammerSat1 + form1.Page4.JhammerTest.Row1.JhammerSat2 + form1.Page4.JhammerTest.Row1.JhammerSat3+ form1.Page4.JhammerTest.Row1.JhammerSat4;

should be

var tempValue = parseInt(form1.Page4.JhammerTest.Row1.JhammerSat1.rawValue) + parseInt(form1.Page4.JhammerTest.Row2.JhammerSat2.rawValue) + parseInt(form1.Page4.JhammerTest.Row3.JhammerSat3.rawValue) + parseInt(form1.Page4.JhammerTest.Row4.JhammerSat4.rawValue);

Message was edited by: jasotastic81 after a couple of typos and fixing a logic problem, this should be right.