Checkbox javascript

Feb 18, 2019

Copy link to clipboard

Copied

Hi.

I need some help in making the right JavaScript for my Price Group checkboxes. I will try to explain.

First of all, my Price Group 1 checkbox is always checked (YES) and locked in normal setup.

What I want help with is when

  • Price Group 6 is checked (YES), Price Group 2, 3, 4 and 5 must be autofilled checked (YES)
  • Price Group 5 is checked (YES), Price Group 2, 3 and 4 must be autofilled checked (YES) - Not Price Group 6
  • Price Group 4 is checked (YES), Price Group 2 and 3 must be autofilled checked (YES) - Not Price Group 5 and 6
  • Price Group 3 is checked (YES), Price Group 2 must be autofilled checked (YES) - Not Price Group 4, 5 and 6
  • Price Group 2 does not execute any JavaScript in this matter

And the other way around

  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 2 is unchecked (OFF), Price Group 3, 4, 5 and 6 must be unchecked (OFF)
  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 3 is unchecked (OFF), Price Group 4, 5 and 6 must be unchecked (OFF), but Price Group 2 will remain checked (YES)
  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 4 is unchecked (OFF), Price Group 5 and 6 must be unchecked (OFF), but Price Group 2 and 3 will remain checked (YES)
  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 5 is unchecked (OFF), Price Group 6 must be unchecked (OFF), but Price Group 2, 3 and 4 will remain checked (YES)
  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 6 is unchecked (OFF), Price Group 6 must be unchecked (OFF), but Price Group 2, 3, 4 and 5 will remain checked (YES)

You must not be able to check (YES) to a higher Price Group unless you also get the Price Groups below. And if you uncheck (OFF) a lower Price Group you also uncheck (OFF) any higher Price Groups.

I hope it make sence to someone who are able to help me setup the right JavaScript.

Thanks in advance!

/Jesper

TOPICS
Acrobat SDK and JavaScript, Windows

Views

158

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Checkbox javascript

Feb 18, 2019

Copy link to clipboard

Copied

Hi.

I need some help in making the right JavaScript for my Price Group checkboxes. I will try to explain.

First of all, my Price Group 1 checkbox is always checked (YES) and locked in normal setup.

What I want help with is when

  • Price Group 6 is checked (YES), Price Group 2, 3, 4 and 5 must be autofilled checked (YES)
  • Price Group 5 is checked (YES), Price Group 2, 3 and 4 must be autofilled checked (YES) - Not Price Group 6
  • Price Group 4 is checked (YES), Price Group 2 and 3 must be autofilled checked (YES) - Not Price Group 5 and 6
  • Price Group 3 is checked (YES), Price Group 2 must be autofilled checked (YES) - Not Price Group 4, 5 and 6
  • Price Group 2 does not execute any JavaScript in this matter

And the other way around

  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 2 is unchecked (OFF), Price Group 3, 4, 5 and 6 must be unchecked (OFF)
  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 3 is unchecked (OFF), Price Group 4, 5 and 6 must be unchecked (OFF), but Price Group 2 will remain checked (YES)
  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 4 is unchecked (OFF), Price Group 5 and 6 must be unchecked (OFF), but Price Group 2 and 3 will remain checked (YES)
  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 5 is unchecked (OFF), Price Group 6 must be unchecked (OFF), but Price Group 2, 3 and 4 will remain checked (YES)
  • If Price Group 2, 3, 4, 5 and 6 are checked (YES) and Price Group 6 is unchecked (OFF), Price Group 6 must be unchecked (OFF), but Price Group 2, 3, 4 and 5 will remain checked (YES)

You must not be able to check (YES) to a higher Price Group unless you also get the Price Groups below. And if you uncheck (OFF) a lower Price Group you also uncheck (OFF) any higher Price Groups.

I hope it make sence to someone who are able to help me setup the right JavaScript.

Thanks in advance!

/Jesper

TOPICS
Acrobat SDK and JavaScript, Windows

Views

159

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 18, 2019 0
Feb 18, 2019

Copy link to clipboard

Copied

One way would be to use a Mouse Up script for each of the check boxes. They would get the value of the check box that it's attached to using event.target.value and get the values of the other check boxes, and then use logic to determine what to do with the other check boxes. It will involve more than a few lines of code, so I'm not going to do it for you here, but if you post what you've tried, we can provide more guidance if needed.

Another option is to create a custom calculate script in a hidden text field. It can determine which field triggered the script using event.source and determine what to do with the other check boxes if one of them was the trigger. This may be a better since all of the code could be placed in a single routine.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 18, 2019 0
Feb 19, 2019

Copy link to clipboard

Copied

Hi George.

Thanks for your reply. Unfortunately, I'm a rookie when it comes to making JavaScript. Therefore I don't have made anything yet, as I don't know where to start.

I have tried to search for similar questions in the community, but can't find anything.

/Jesper

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 19, 2019 0