Subtract value from fixed number based on checkbox selections

Avatar

Avatar
Validate 1
Level 1
stephenf8734174
Level 1

Like

1 like

Total Posts

45 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
stephenf8734174
Level 1

Like

1 like

Total Posts

45 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
stephenf8734174
Level 1

30-03-2016

Hi, I've looked everywhere in this forum and can't find the exact answer I'm after.

I have a numeric field that starts with a fixed value of '44', and 6 checkboxes. For each checkbox selected I want '2' subtracted from '44' e.g. if 1 checkbox is selected the value becomes '42' and if two checkboxes are selected the value becomes '40' and so on.

Is this possible? I'm going crazy trying to make this work.

Thanks for any help.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

30-03-2016

Try this: Add code to the change event of the checkboxes

For example:

if (this.rawValue == "1") {

  this.resolveNode("numericField1").rawValue = this.resolveNode("numericField1").rawValue - 2;

}

if (this.rawValue == "0") {

  this.resolveNode("numericField1").rawValue = this.resolveNode("numericField1").rawValue + 2;

}

//the this.rawValue of 1 is a checked checkbox, 0 is unchecked. Using this code, a checked checkbox would subtract 2 from numericField1, and unchecked checkbox would add 2.

I had problems with this for a while because i had it in the click event not the change event.

Answers (2)

Answers (2)

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

30-03-2016

Glad to help. This one stumped me at first.

Avatar

Avatar
Validate 1
Level 1
stephenf8734174
Level 1

Like

1 like

Total Posts

45 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
stephenf8734174
Level 1

Like

1 like

Total Posts

45 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 1
Applaud 5
View profile
stephenf8734174
Level 1

30-03-2016

That is brilliant! Thanks for that - worked perfectly!