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

Script not working

kimmerdog
Registered: Apr 24 2008
Posts: 20

I have a document whereby if I press a button for New Employee, I get a drop down menu asking for Full-Time, Contract, etc. If I select Contract a response box should open asking for date.
 
My script will allow me as far as selecting Contract, but I cannot get the response box to open.
 
What am I missing? Do I have to put in a validation script?
 
Please advise.

My Product Information:
Acrobat Pro 8.0, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Buttons have no validation scripts.

Post your code, and any error messages you're getting.

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

kimmerdog
Registered: Apr 24 2008
Posts: 20
try67 wrote:
Buttons have no validation scripts.Post your code, and any error messages you're getting.
sorry, it's a checkbox.

The Checkbox opens a drop-down menu. You have a choice of 4 options. Dependent upon the option, which auto-populates another field, it will trigger a date required response box. For example, if you choose "Full-time" the box does not open. If you choose "Contract" the date response box opens for data entry which then populates the date expiry date field.

currently, we can only get it to open the response box for everything on the drop-down target field. What are we missing? We have two of us trying to figure it and we know it is something so simple. Please advise?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Like I said, post your code and any error message you're getting in the JS console.
I can't possibly guess what is not working without seeing the code you're using.

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

kimmerdog
Registered: Apr 24 2008
Posts: 20
This is the code that needs fixing. Any support would be appreciated.

var cRtn = app.popUpMenu("Full Time","Contract","Student","Part Time","-","Consultant","Temp Agency Staff");
if(cRtn != null)
this.getField("Result1").value = cRtn;
if(cRtn = "Contract","Student","Consultant","Temp Agency Staff")


var t = this.getField("date"); // the target field
var cResponse = app.response({
cQuestion: "Please enter expiry date",
cTitle: "Expiry Date"});
{
// places the data from the dialog to the target field
t.value = cResponse;
}

kimmerdog
Registered: Apr 24 2008
Posts: 20
This is the code that needs fixing. Any support would be appreciated.

var cRtn = app.popUpMenu("Full Time","Contract","Student","Part Time","-","Consultant","Temp Agency Staff");
if(cRtn != null)
this.getField("Result1").value = cRtn;
if(cRtn = "Contract","Student","Consultant","Temp Agency Staff")


var t = this.getField("date"); // the target field
var cResponse = app.response({
cQuestion: "Please enter expiry date",
cTitle: "Expiry Date"});
{
// places the data from the dialog to the target field
t.value = cResponse;
}

Hoyane
Registered: Nov 26 2011
Posts: 33
I got your code to work. I suspect your mistake is here
this.getField("Result1").value = cRtn;
Result1 should be the name of your check box.

kimmerdog
Registered: Apr 24 2008
Posts: 20
Hoyane wrote:
I got your code to work. I suspect your mistake is here
this.getField("Result1").value = cRtn;
Result1 should be the name of your check box.
This is what I need:

When I click the box for New employee, I want to get a drop down box showing (full time, part time, contract, Student, etc.). If I select, Contract, I want a response box to open to enter a date which will be placed in another area on the document.

What you have given me solves one part but as you will notice in the coding, I can't get the response box to open when I click on Contract.

This is urgent can anyone help me?
kimmerdog
Registered: Apr 24 2008
Posts: 20
Hoyane wrote:
I got your code to work. I suspect your mistake is here
this.getField("Result1").value = cRtn;
Result1 should be the name of your check box.
This is what I need:

When I click the box for New employee, I want to get a drop down box showing (full time, part time, contract, Student, etc.). If I select, Contract, I want a response box to open to enter a date which will be placed in another area on the document.

What you have given me solves one part but as you will notice in the coding, I can't get the response box to open when I click on Contract.

This is urgent can anyone help me?
Hoyane
Registered: Nov 26 2011
Posts: 33
This is the full code. It works for me exactly as you are asking.
When any one of the options is selected a popup comes up asking for a date, after you enter a date the "date" field is filled with the date.

Result1 is the name of your checkbox that brings up the options.
date is the name of the text box you want the date to go to.
This code is placed in the action area of the checkbox in a "Mouse Down" action to run javascript.
If it still is not working and there is more code to your project not revealed here, maybe something else is breaking the date popup. If that's the case, Without seeing the entire code I can't figure it out.
But again this code works for sure.
In my tests the only reason the popup did not come is because result1 was not the name of the checkbox.
If i can be of further help let me know.



var cRtn = app.popUpMenu("Full Time","Contract","Student","Part Time","-","Consultant","Temp Agency Staff");
if(cRtn != null)
this.getField("Result1").value = cRtn;
if(cRtn = "Contract","Student","Consultant","Temp Agency Staff")


var t = this.getField("date");
var cResponse = app.response({
cQuestion: "Please enter expiry date",
cTitle: "Expiry Date"});
{
t.value = cResponse;
}

kimmerdog
Registered: Apr 24 2008
Posts: 20
Hoyane wrote:
This is the full code. It works for me exactly as you are asking.
When any one of the options is selected a popup comes up asking for a date, after you enter a date the "date" field is filled with the date.

Result1 is the name of your checkbox that brings up the options.
date is the name of the text box you want the date to go to.
This code is placed in the action area of the checkbox in a "Mouse Down" action to run javascript.
If it still is not working and there is more code to your project not revealed here, maybe something else is breaking the date popup. If that's the case, Without seeing the entire code I can't figure it out.
But again this code works for sure.
In my tests the only reason the popup did not come is because result1 was not the name of the checkbox.
If i can be of further help let me know.



var cRtn = app.popUpMenu("Full Time","Contract","Student","Part Time","-","Consultant","Temp Agency Staff");
if(cRtn != null)
this.getField("Result1").value = cRtn;
if(cRtn = "Contract","Student","Consultant","Temp Agency Staff")


var t = this.getField("date");
var cResponse = app.response({
cQuestion: "Please enter expiry date",
cTitle: "Expiry Date"});
{
t.value = cResponse;
}
It works for us too, but we don't want the date response box to come up when we select Full Time, Part Time or -.

any suggestions.


Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi Kimmerdog,

Maybe these will help you develop and debug your script-

http://acrobatusers.com/tutorials/conditional-execution

http://acrobatusers.com/tutorials/how-debug-your-script

Hope this helps,

Dimitri

Hoyane
Registered: Nov 26 2011
Posts: 33
OK I figured it out.
Got it working reading about conditional execution. I thought there was suppose to be a else statement but it works perfect like this..
one is the name of your button that brings up the options.
date is the name of the text box you want the date to go to.
This code is placed in the action area of the checkbox in a "Mouse Down" action to run javascript.



var cRtn = app.popUpMenu("Full Time","Contract","Student","Part Time","-","Consultant","Temp Agency Staff");
if(cRtn != null)
this.getField("one").value = cRtn;
if(cRtn = "Contract","Student","Consultant","Temp Agency Staff")



var t = this.getField("date");
if (this.getField("one").value=="Consultant")
var cResponse = app.response({
cQuestion: "Please enter expiry date",
cTitle: "Expiry Date"});
{
t.value = cResponse;
}


var t = this.getField("date");
if (this.getField("one").value=="Temp Agency Staff")
var cResponse = app.response({
cQuestion: "Please enter expiry date",
cTitle: "Expiry Date"});
{
t.value = cResponse;
}


kimmerdog
Registered: Apr 24 2008
Posts: 20
This works fine except I want the "one" field to show one of the following "Full Time","Contract","Student","Part Time","-","Consultant","Temp Agency Staff" and after it shows then I want the date box dependent on what is in the text field.

I am missing the code that will show the word in the text field and then show the date field.


Hoyane
Registered: Nov 26 2011
Posts: 33
In your code what is "one"? Because i made this code for a button or check box and cant put text in a button Or did you want the info to go into a text box next to the button/check box?

To get a prefix just change the t.value lines to
t.value = "What you want it to say:\n" + cResponse;
Hoyane
Registered: Nov 26 2011
Posts: 33
The code in my above post was bad. Had several problems once i started playing with it.
This code is cleaner i think and sends a result no matter whats selected.


var cRtn = app.popUpMenu("Full Time","Contract","Student","Part Time","-","Consultant","Temp Agency Staff");
if(cRtn != null)
this.getField("HiddenTextField1").value = cRtn;


var a = this.getField("TextField2");
if (this.getField("HiddenTextField1").value=="Consultant")
var cResponse = app.response({
cQuestion: "Please enter expiry date",
cTitle: "Expiry Date"});
if (this.getField("HiddenTextField1").value=="Temp Agency Staff")
var cResponse = app.response({
cQuestion: "Please enter expiry date",
cTitle: "Expiry Date"});
{
a.value = cRtn + ":\n" + cResponse;
}

var b = this.getField("TextField2");
if (this.getField("HiddenTextField1").value=="Full Time")
b.value = cRtn ;
if (this.getField("HiddenTextField1").value=="Contract")
b.value = cRtn ;
if (this.getField("HiddenTextField1").value=="Student")
b.value = cRtn ;
if (this.getField("HiddenTextField1").value=="Part Time")
{
b.value = cRtn ;
}

console.println("cResponse: " + cResponse);
console.println("cRtn: " + cRtn);
console.println("a.value: " + a.value);
console.println("b.value: " + b.value);