Hallo there!
I have a problem to set checkboxes behavior. I have 10 checkboxes in the vote list. I'm trying to set those to act on this way: when someone mark 5/10 checkboxes, other 5 are not accessible anymore.
Is it possible to do this?
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi,
You need to scripts in the click event and the layout:ready event of each checkbox. In addition you need either a field to keep track of scores or a global variable to do this. Here I have used a numeric field.
The script in the click event adds the score (or takes 1 away if a checkbox is deselected):
if (this.rawValue == "1")
{
score.rawValue += 1;
}
else
{
score.rawValue -= 1;
}
if (this.rawValue == "0" && score.rawValue == 5)
{
this.access = "readOnly";
}
else
{
this.access = "open";
}
Views
Replies
Total Likes
Hi,
You need to scripts in the click event and the layout:ready event of each checkbox. In addition you need either a field to keep track of scores or a global variable to do this. Here I have used a numeric field.
The script in the click event adds the score (or takes 1 away if a checkbox is deselected):
if (this.rawValue == "1")
{
score.rawValue += 1;
}
else
{
score.rawValue -= 1;
}
if (this.rawValue == "0" && score.rawValue == 5)
{
this.access = "readOnly";
}
else
{
this.access = "open";
}
Views
Replies
Total Likes
Thanks Niall,
Right in the middle
Views
Replies
Total Likes
Niall, can i ask you one more?
How to set those 5 checkboxes to be required? So, if someone want to complete the vote list, 5/10 checkboxes must be marked.
Thanks
Views
Replies
Total Likes
Hi,
It depends on what the following action is. Is the form being submitted?
One option would be to not assign the checkboxes as required, but track the score value. For example the submit button would be hidden/readOnly unless the score was 5.
In that case the submit button could have the following in the layout:ready event
if (score.rawValue == 5)
{
this.presence = "visible";
}
else
{
this.presence = "invisible";
}
You can script an object to be required, but I think it is a bit too much trouble here as you don't know which of the 10 the user will tick and you would then have to turn off the required status on the 5 remaining un-ticked ones.
Let me know what you think,
Niall
Views
Replies
Total Likes
If either of you is interested, John Brinkman wrote a blog entry about this. You can read it here if you'd like:
http://blogs.adobe.com/formfeed/2008/12/adventures_with_javascript_obj.html
Hi,
Yes, the vote list contains e-mail submit button and hide/readonly option sounds good. But I have 3 different groups of checkboxes/candidates on the single page. I did scrypting as you told me in the first answer and everything works beautiful (look the link).
https://acrobat.com/#d=Ek-jpQcSCDz770G-yOstfQ
first group: I allow and require 5 marked checkboxes.
second group: I allow and require 3 marked checkboxes.
third group: I allow and require 2 marked checkboxes.
Now, how to scrypt submit button?...or maybe there is some other solution...hope you understand what i'm trying to do....
thanks for helping me
Views
Replies
Total Likes
thanks djaknow
Views
Replies
Total Likes
Hi,
You will be able to test against the three separate scores and then change the visibility of the submit button. If just need s simple if statement, something like:
if (score1.rawValue == 5 && score2.rawValue == 3 && score3.rawValue == 2)
{
this.presence = "visible";
}
else
{
this.presence = "invisible";
}
I can't access the file you put on Acrobat.com - you will need to share it and click OK to save the share.
It's St. Patrick's Day here, so I won't be able to get to it for a few hours.
Niall
Views
Replies
Total Likes
Thanks!
I put the file on share, so when you have a time.
Enjoy celebration
Marko
Views
Replies
Total Likes
Thank you,
Here is the form: https://acrobat.com/#d=xdgAZtSFsa0ky890ZeXUJw
Check out the script in the layout:ready event of the submit button. Because the button is hidden, you could include a bit of text to let the user know that when they complete the checkboxes, the submit button will be available.
Script in the layout:ready event isn't the most efficient because it fires at each change in the form. But if the form is short it won't affect performance too much.
Slan,
Niall
Just great
I became interested in javascript. There is a lot to learn.
Thanks for the help!
Marko
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies