Copy link to clipboard
Copied
I'm creating a sheet for a game. I have a list of skills with 3 radio buttons stacked on top of each other next to each skill. The idea is that if you do not have that skill, the "Blank" radio button is visible. If you have partial skill in it, the "Partial" button (which is a half circle image) is visible, and if you are fully skilled, the "Skilled" button is visible (full circle image). When one is visible, the other two are hidden. I am using Run Javascript on Mouse Up as the action for each button to hide/show each one. That script is very simple and looks like this:
this.getField("PartialSkillLift").display = display.visible;
this.getField("SkilledLift").display = display.hidden ;
this.getField("BlankLift").display = display.hidden ;
That part is working fine, but what i would like to add to it that i can't seem to get figured out is i would like the skill to show a number or do a calculation based on which button is showing. So, if the Blank button is visible, it just displays the number from a stat bonus (i.e. "StrengthBonus" field). If the Partial button is shown, it does the calculation of "StrengthBonus" + 1). And if the Skilled button is shown, it does the calculation "StrengthBonus + Level + 3" ("Level" is also a field already set up).
I have this in the "Lift" field currently...
Copy link to clipboard
Copied
"all of the button fields are just always visible " That's because these lines of code are setting them to visible:
Copy link to clipboard
Copied
Thank you so much for the assistance with the carousel button. That is SUPER nice, to only have one button for each skill instead of three for each. Way cleaner. I haven't had a chance to have the new buttons values start feeding the Skill yet, but thats my next task. Was just really excited to find out that the buttons could carousel in that way though. Very helpful, and i appreciate the reply!
Copy link to clipboard
Copied
You can use the same stored icons for all your buttons that will have the same click through images. Button fields don't have a text property but you can store a value for the different icons being display in a hidden text field, or in the tooltip. Example:
event.target.userName=0;
Copy link to clipboard
Copied
So, i have gone into the field that the carousel button was supposed to feed values into and entered some script. I'm not sure what i'm doing incorrectly. When the "strbonus" field has a number entered into it, the script is populating into the "Lift" field the way it should (especially since the buttons default state is "Blankdot")...but when i cycle through the other button presses...it's not changing the values the way it should. I'm obviously missing something in my script that is needed, i just don't know what it is. Below is the script i have entered into the "Lift" field:
Copy link to clipboard
Copied
You need to use two equal signs for comparison in the 'if' and 'else' statements:
event.target will work in the field where the script is, if you want to get tooltip from other fields then you can do it like this:
if(this.getField("Lift").userName == "Pardot")
Copy link to clipboard
Copied
As @Nesa Nurani said, you need 2 equal signs for each comparison. You also need to name the button field instead of event.target, which is the Lift field in this case.
if(this.getField("ButtonFieldName").userName=="Blankdot")
Replace "ButtonFieldName" with the actual name of the field.
Copy link to clipboard
Copied
I greatly appreciate all the help and patience. A lot of this is very new for me, so i'm really trying to learn/understand best i can. I actually wondered if the "ButtonFieldName" should have been called out somewhere, but wasn't sure exactly how it should go, so when i read your response this morning i was excited that that would solve it.
I have altered the code according to the recommendations from you both, and it now looks as follows:
However...it still isn't doing the calculations for when the button is clicked to "Partdot" or "Skilldot". When a value is entered into "strbonus", it shows in "Lift" because the "Blankdot" is shown, but it doesn't change as i cycle through the button changes.
Copy link to clipboard
Copied
Changing tooltip by clicking the button will not trigger calculation script, instead you have a couple of choices, either create another calculation script and place it in the button as Mouse UP or create document level script inside a function then call function from your calculated field and from the button.
Copy link to clipboard
Copied
Add this line at the end of your button script:
this.calculateNow();
Copy link to clipboard
Copied
Oh my goodness, thank you SO MUCH!! It is now working exactly the way i need it to!! I GREATLY appreciate your assistance!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now