I seem to really have problems with this type of script!!! /Spacing is weird after I pasted it. I'm not getting any error message but when I click the button to test it, nothing happens.
//Create a variable to hold the document object
var
v1 = (form1.assocInfo.AssocType.rawValue);
var
v2 = (form1.assocInfo.EffectiveDate.rawValue);
var
v3 = (form1.assocInfo.firstName.rawValue);
//var v4 = (form1.assocInfo.MiddleInit.rawValue);
var
v5 = (form1.assocInfo.LastName.rawValue);
var
v6 = (form1.assocInfo.EmployeeID.rawValue);
var
v7 = (form1.assocInfo.OfficeLoc.rawValue);
var
v8 = (form1.assocInfo.AssocExt.rawValue);
var
v9 = (form1.assocInfo.MngrExt.rawValue);
var
v10 = (form1.assocInfo.DeptMgr.rawValue);
//var v11 = (page1.topForm.subForm1.directReports.rawValue);
//var v12 = (page1.topForm.subForm1.perfRating.rawValue);
//var v13 = (page1.topForm.request.howLongWorking.rawValue);
//Associate Type
if
((v1 == "") || (v1 == null)) {
xfa.host.messageBox( "Please select a type of request" );
xfa.host.setFocus("form1.assocInfo.AssocType");
}
//Effective Date
else
{
if ((v2 == "") || (v2 == null)) {
xfa.host.messageBox( "Please enter an effective date" );
xfa.host.setFocus("form1.assocInfo.EffectiveDate");
}
//FIRST NAME
else {
if ((v3 == "") || (v3 == null)) {
xfa.host.messageBox( "Please enter associate's first name" );
xfa.host.setFocus("form1.assocInfo.firstName");
}
//Last Name
else {
if ((v5 == "") || (v5 == null)) {
xfa.host.messageBox( "Please enter associate's last name" );
xfa.host.setFocus("form1.assocInfo.LastName");
}
//EMPLOYEE ID
else {
if ((v6 == "") || (v6 == null)) {
xfa.host.messageBox( "Please enter associate's employee ID" );
xfa.host.setFocus("form1.assocInfo.EmployeeID");
}
//OFFICE Location
else {
if ((v7 == "") || (v7 == null)) {
xfa.host.messageBox( "Please enter associate's office location" );
xfa.host.setFocus("form1.assocInfo.OfficeLoc");
}
//ASSOCIATE EXTENSION
else {
if ((v8 == "")|| (v8 == null)){
xfa.host.messageBox( "Please enter associate's phone extension" );
xfa.host.setFocus("form1.assocInfo.AssocExt");
}
//MANAGER EXT
else {
if ((v9 == "") || (v9 == null)) {
xfa.host.messageBox( "Please enter your phone extension" );
xfa.host.setFocus("form1.assocInfo.MngrExt");
}
//MANAGER NAME
else {
if ((v10 == "") || (v10 == null)) {
xfa.host.messageBox( "Please enter your name" );
xfa.host.setFocus("form1.assocInfo.DeptMgr");
}
else {
Button4.execEvent("click");
}
}
}
}
}
}
}
}
}
}
Thanks for any help.
MDawn
Views
Replies
Total Likes
Hi Margaret,
I suspect that it is something to do with the nested if/else statements.
The variable declarations are okay, but you could lose the brackets:
var v1 = form1.assocInfo.AssocType.rawValue;
It is difficult to say without seeing the form, but I would try something like this:
if (v1 == "" || v1 == null)
{
xfa.host.messageBox( "Please select a type of request" );
xfa.host.setFocus("form1.assocInfo.AssocType");
}
else if (v2 == "" || v2 == null)
{
xfa.host.messageBox( "Please enter an effective date" );
xfa.host.setFocus("form1.assocInfo.EffectiveDate");
}
...
else
{
Button4.execEvent("click");
}
This will work through the fields/variables and give a warning for the FIRST error it comes to. Maybe this doesn't suit the logic, but give it a try.
Also note that I have dropped brackets in the if statements. This isn't causing the problem, but just makes the code cleaner.
I can't look at the form now and I am out tomorrow, so hopefully this will sort it.
Niall
Views
Replies
Total Likes
I'll try that thanks.
Margaret Dawn
630-850-1065
Views
Replies
Total Likes
I tried the suggestions you made and it still doesn't work.I've compared the script to a similar script in another form that is working and I can't see any differences. I'm not sure what I'm overlooking so any help is appreciated. I'm uploading the form. The button in question is the Submit SAR to Technical Services on page 4.
Thanks,
MDawn
Views
Replies
Total Likes
Hi,
Make sure that the language is set to JavaScript. Open the JavaScript Console when previewing the form (Control+J) and see are there any errors when you interact with the form.
You will need to upload the form to a file sharing site like Acrobat.com and then post the published URL here.
Hope that helps,
Niall
Views
Replies
Total Likes
I have checked Ctrl+J and no errors are listed. The language is set to JavaScript. I'll upload the form and post the URL.
Thanks,
Margaret Dawn
Views
Replies
Total Likes
Acrobat.com is currently unavailable. I'll post when I can.
Margaret Dawn
630-850-1065
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies