Check or Uncheck Checkbox based on Textbox value Adobe Acrobat Stamp Javascript

2.6k views Asked by At

It is for Adobe Acrobat Javascript:

I'm trying this code but failed for two days. I'm trying to put this code in textField Calculate Tab and in Custom Calculation Script.

Any help will be appreciated.

And let me also tell you what I'm trying to achieve. I want that if user put any value in textField it check the value if it is "Yes" it should mark the check box Checked. and if it is No it will do nothing or uncheck the checkbox.

var subText= "Subcontractor Yes or No";
var cTitle = "Document Data for Stamp";

if(event.source.forReal && (event.source.stampName =="#New123"))
{
event.value = app.response(subText , cTitle);

if(this.getField("subtext").value =="Yes")
{
this.getField("SubCheckbox").value="On";
}

if(this.getField("subtext").value =="No")
{
this.getField("Subcheckbox").value="Off";
}

}
2

There are 2 answers

0
Zohaib Akbar On

I found the solution and it worked for me perfectly.

var subText= "Subcontractor Yes or No";
var cTitle = "Document Data for Stamp";

if(event.source.forReal && (event.source.stampName =="#New123"))
{
event.value = app.response(subText , cTitle);

if(this.event.value =="Yes")
{
this.getField("Subcheckbox").value="On";
}

if(this.event.value =="No")
{
this.getField("Subcheckbox").value="Off";
}
}
1
Gregorio Lopez On

You should try something like this in the onchange function of your textbox

function myScript() {
    var text = document.getElementById("textbox").value;
if(text == "Yes")
    document.getElementById("checkbox").checked = true;
else
    document.getElementById("checkbox").checked = false;
}