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

set text field value when button is clicked

smilem
Registered: Apr 1 2008
Posts: 101

Should be simple but just doesn't work somehow:

I have button that needs to check if textfield boldval value is 0 if true then set it to 1 else do the "else" part of the script:

set a textfield named boldval to 1 if it's value is 0
//check if boldval textfield value is 0
if (boldval.rawValue == "0")
//if value is not 0 set it to 1
{
boldval.rawvalue = "1";

}
else
{
boldval.rawvalue = "0";

try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
You're using the wrong operator. In the comment you write "//if value is not 0 set it to 1", but you use the equals (==) operator. Change the first line to:

if (boldval.rawValue != "0")

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

smilem
Registered: Apr 1 2008
Posts: 101
The equals (==) operator is used to evaluate if both variables are the same, and the if statement should work accordingly to this evaluation


Well it doesn't work, but I managed to make it work using checkbox like this:

if (CheckBox2.rawValue == "0" )
{
CheckBox2.rawValue = 1;
}
else
{
CheckBox2.rawValue = 0;
}

And on form initialize I have this:

if (CheckBox2.rawValue == "1" )
{
Button9.fillColor = "222,229,255"
}
else
{
Button9.fillColor = "212,208,200"
}

How to make the same the textfield?
smilem
Registered: Apr 1 2008
Posts: 101
anyone?

I can ask it in different way:
What code I need to use in button click event to make an empty text field display "ABC123"

this does not work:

CheckBox2.rawValue = ABC123;