These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

How to use setAction() to perform MousUp on a radio button?

David Dunn
Registered: Oct 28 2010
Posts: 116
Answered

I am in search of the proper syntax for using 'setAction()' to perform a MouseUp action on a radio button. My target is the second radio button in a 2 button set.
 
My script attached to a button "A" sets the value of a radio button named "rdo.S.HasAgent" to "No" and thereby causes the button to appear selected. However, merely setting the value of "rdo.S.HasAgent" does not trigger the actions attached to it. I am hoping I can use 'setAction()' to actually trigger the actions attached to the target radio button's MouseUp event. Here is my script as it exists without "setAction()" employed.
 
var rdoSA1 = this.getField("rdo.S.HasAgent.1")//the ".1" is the index of the second button in the set of 2 buttons
 
if (event.target.value == "No")
{
rdoSA1.value = "No"
}
 
Your help in how to use setAction() to perform a MouseUp action would be much appreciated, and thank you.

David D

My Product Information:
Acrobat Pro 9.4, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
I would create a document level function and then as needed to run the code, call that function.

George Kaiser

David Dunn
Registered: Oct 28 2010
Posts: 116
Thank you, but, regardless of whether a document level or field level script, my inquiry is to the proper syntax for using "setAction("MouseUp")" to cause the action to be sent to the radio button. The syntax is what I am having trouble with.

David D

David Dunn
Registered: Oct 28 2010
Posts: 116
Also, I may be so far off that "setAction()" at the field level is not the correct method. What I am looking for is a means analogous to a macro command like "SendKeys()" which is used as a pro-grammatical mouse click on a button ... a script method that will do the same thing that actually clicking on the target radio button does.

David D

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
'setAction' is the method to insert by JavaScript a document level function or a field action. There is no send key type function. As explained, you create a document level function and then call that function for the mouse up action and whenever else you want to execute that action.

George Kaiser

David Dunn
Registered: Oct 28 2010
Posts: 116
Perhaps I've done a poor job of explaining my need. Let me try again if I may. I cannot determine how construct the arguments and/or statements to be used in conjunction with my variable rdoSA1 and 'setAction()' so that when I call the function with a script attached to radio button set "A" on one page, clicking that radio button will "send" a mouse up action to my target radio button set "B" on another page. Restated more succinctly, I want my clicking on radio button "A.1" to trigger the selection of radio button "B.1" as if I independently clicked "B.1". If you had an example of how setAction("MouseUP") is used to do this, that would be a terrific help.

David D

try67
Expert
Registered: Oct 30 2008
Posts: 2398
That's not possible to do. You can either call a function, or set the other radio button's value.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

David Dunn
Registered: Oct 28 2010
Posts: 116
I don't understand what I am not saying correctly. I've tried to say this very clearly each time. I understand the concept of setting up and calling a function. I know how a function is structured. HOWEVER, I don't know how to use setAction() and "MouseUP" in the function or how to direct it at the target radio button. Will someone please show me an example?

David D

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Accepted Answer
You misunderstand how setAction works, I think. It's not used to launch an action associated with a trigger, but to create such an action.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

David Dunn
Registered: Oct 28 2010
Posts: 116
Now we're getting at the root of the problem. I suspected but was not sure setAction() was not the ticket. In my original post I said that my existing script sets the value of a radio button - I do know how to do that - but that I am hoping I can use 'setAction()' to actually trigger (e.g. launch) the actions attached to the target radio button's MouseUp event. My objective is to find a way in JavaScript that will launch an action, i.e., that will have the effect of having physically clicked on the radio button, something analogous to a macro command like "SendKeys."

David D

try67
Expert
Registered: Oct 30 2008
Posts: 2398
That's why I wrote earlier that it's not possible...

What you want to do is made out of two parts: setting the value of the radio button, and launching the command that is associated with the MouseUp event for that radio button. You can achieve those two things separately, though:
- You set the radio-button's value by accessing its value property.
- You launch the action associated with the MouseUp event by placing that action at the document-level inside a function and calling it from both the MouseUp event of the radio-button AND from your other-button.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
As previously posted, you need to write a document level function and then call that function in the various JavaScript actions when you want that code to run.

So where does JavaScript live in Acrobat? by Thom Parker
Entering Document Scripts by Thom ParkerIf you were to create a document level function with the following code:

function MyAlert(sMsg) {
app.alert(sMsg, 3, 0, "My Alert'");
}

You can call this function as button mouse up action with:

MyAlert("Some one pushed me!");

You can use the same code any where else you want that message to appear, like another button mouse up action or page open action.

George Kaiser

David Dunn
Registered: Oct 28 2010
Posts: 116
George and Gilad,

Now I understand and thank you both for bearing with me. At first I thought each of you was telling me setAction() could be used to launch an action in a targeted field but it had to be deployed through a function. Each of your last 2 explanations answers my inquiry very clearly. Much appreciated.

With my programming experience limited to macros I find myself approaching objectives in JavaScript for Acrobat the same way I am accustomed to doing so in macros. It's a different animal, but I like the way JS works more all the time.

David

David D