Copy link to clipboard
Copied
Hi,
Can any one help me on adding change event to the check box?
1. If the check box is marked it will bring us to new page. If it is not marked needs to remain in same page.
2. how to add events to the fields in the adobe reader through javascript.
Thank you
Ariv
Copy link to clipboard
Copied
You can't add any actions with Reader. Do you have access to Acrobat?
Copy link to clipboard
Copied
Yes I am having Adobe Acrobat Pro DC.
Copy link to clipboard
Copied
Is there a reason you don't want to use a button? It's more flexible in what actions can be used with it and a much more standard means of navigation than a check box.
Copy link to clipboard
Copied
A check-box field doesn't have a "change" event, like a text box, for example. However, you can utilize other event to achieve the same thing. For example, the MouseUp event. You can use event.target.value to access the current value of the field in that event, and then proceed with the rest of your logic.
Copy link to clipboard
Copied
I tried
chkbox = app.trustedFunction(function()
{
app.beginpriv();
var aRCBRect = [18,50,80,100]
var f=this.addField("myCheck", "checkbox",1,aRCBRect);
f.borderStyle = border.b;
f.exportValues=["Yes"];
f.lineWidth = 1;
f.strokeColor=color.black;
f.style=style.ch
f.textSize=35;
f.value="Off"
f.setAction("MouseUp", validate(f)");
function validate(x)
{
if(x.value=="Yes")
{
this.pageNum++;
}
}
app.endPriv();
});
app.addToolButton({
cName:"chkbox",
cExec:"chkbox()"
cTooltext: "Check Box"});
it is working fine in document level script with out toolbutton.
While trying to add this script in folder level using toolbutton. it is not working. I am getting "validate is not defined 1: Field:Mouse Up Up" error. here validate function i have defined. can u help on this.
can u tell me what is the use of the line "f.exportValues=["Yes"];" in the script.
Thank you
Ariv
Copy link to clipboard
Copied
You defines the function "validate" inside of function "chkbox". Put the definition at top-level.
Copy link to clipboard
Copied
Hi,
two functions i have used. one is 'chkbox' function that is called by toolbutton. And another function is 'validate' that is inside the 'chkbox' function.
Copy link to clipboard
Copied
Couple of issues. First of all, this line is incorrect:
f.setAction("MouseUp", validate(f)");
You're missing a double-quote before validate, and also at the moment the field is clicked, "f" is not a defined variable.
Instead, use this:
f.setAction("MouseUp", "validate(event.target);");
Copy link to clipboard
Copied
I have tried. Still it is showing error "validate is not defined 1: AcroForm:myCheck: Annot4:Mouse Up:Action1".
I want check box to respond on my mouse click.
Copy link to clipboard
Copied
Forget about the function. Just use this:
f.setAction("MouseUp", "if (event.target.value!=\"Off\") this.pageNum++;");
Copy link to clipboard
Copied
very useful. It is working now. Thank you very much.
Ariv
Copy link to clipboard
Copied
Hi,
I am having another doubt in this can u able to clarify this.
chkbox = app.trustedFunction(function()
{
app.beginpriv();
var aRCBRect = [18,50,80,100]
var f=this.addField("myCheck", "checkbox",1,aRCBRect);
f.borderStyle = border.b;
f.exportValues=["Yes"];
f.lineWidth = 1;
f.strokeColor=color.black;
f.style=style.ch
f.textSize=35;
f.value="Off"
f.setAction("MouseUp", validate(f));
function validate(x)
{
app.alert("Success");
}
app.endPriv();
});
app.addToolButton({
cName:"chkbox",
cExec:"chkbox()"
cTooltext: "Check Box"});
above is working fine. If I wanted to call another function at MouseUp event what should i need to do. How I can call multiple functions at mouse up event.
Thank you
Copy link to clipboard
Copied
I got the solution to call more than one function.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now