By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

Check All Box with on a Adobe 8.0 pdf form

kcdoell
100+
P: 230
Hello:

I am a newbie with Java coding... I have a form that I created in Word. Within that form it had a place where the user could selected certain states or all states via a checkbox. I used VBA coding to do this and it works great. My problem is now I have to convert the form to an Adobe 8.0 pdf form. The conversion process does not bring over the VBA logic. So I placed the check boxes for each state and then inserted an object (button) for selecting all the State check boxes if it was applicable:

I used the following code that I believed would work but nothing happens on execution:

My Checkboxes were named the following (I have 50 of these checkboxes):

SS.1
SS.2
SS.3
SS.4
SS.5

Then I thought the code would be inserted in my button object:

Expand|Select|Wrap|Line Numbers
  1. var s="";
  2. for(var i=1;i<51;i++){
  3.     s="SS."+i;
  4.     getField(s).value="Yes"
  5. }
  6.  
______________

Does that make sense to those who understand the inner workings of Java?

Any ideas would be helpful.

Thanks,
Feb 4 '08 #1
Share this Question
Share on Google+
27 Replies


BigDaddyLH
Expert 100+
P: 1,216
How did you manage to inject Java into a PDF?
Feb 4 '08 #2

kcdoell
100+
P: 230
Using the Adobe LiveCycle Designer that comes with the Adobe 8.0 Professional version
Feb 4 '08 #3

BigDaddyLH
Expert 100+
P: 1,216
Using the Adobe LiveCycle Designer that comes with the Adobe 8.0 Professional version
Are you sure you know what language you're using? Are you sure it's Java and not ECMAScript (sometimes called JavaScript)? Because the statement

var s="";

sure looks like the latter.
Feb 4 '08 #4

kcdoell
100+
P: 230
The Adobe software says the language needs to be JavaScript. Like I said I have limited knowledge about Java so my coding is most likely wrong and that is why it is not working.....

I attempted to create a loop expression in the object called "Select All".

When that object is selected the Adobe software allows me to embedded the JavaScript (The code I posted) in different event selections; I choose the mouseup selection.
Feb 4 '08 #5

BigDaddyLH
Expert 100+
P: 1,216
The Adobe software says the language needs to be JavaScript. Like I said I have limited knowledge about Java so my coding is most likely wrong and that is why it is not working.....
JavaScript and Java are unrelated. I have moved this thread to the JavaScript forum.
Feb 4 '08 #6

acoder
Expert Mod 15k+
P: 16,027
In JavaScript, you use the checked property to check a checkbox.
Feb 5 '08 #7

kcdoell
100+
P: 230
Thanks, I will look into the link though it is all a little greek to me since I am a Newbie with Java Script.

Do you have an idea on how the code would go given my description? Should I apply the code in the button object that I have on the form called "Select All States"?
Feb 5 '08 #8

acoder
Expert Mod 15k+
P: 16,027
If, in the code in the first post, getField does get the checkbox field, then instead of setting the value, set the checked property to true: getField(s).checked = true.
Feb 6 '08 #9

kcdoell
100+
P: 230
I looked into the website link that was provided. It is referencing code that is for a web based application. Mine is in the pdf form itself so I am not understanding the correct coding due to the other tagging references which are probably not all relevant to my problem.

I have tried several things in the mouseup and click event with no positive results. On my form the check boxes are not checked. I simply want to create a button that would check all the "check boxes"

Does anybody have any idea where I am going wrong????

Thanks,

Keith.
Feb 6 '08 #10

acoder
Expert Mod 15k+
P: 16,027
Sorry, I'm not too familiar with Adobe's PDF JavaScript, but if you post your code, I can have a look and maybe come up with suggestions.
Feb 6 '08 #11

kcdoell
100+
P: 230
Expand|Select|Wrap|Line Numbers
  1. var s="";
  2. for(var i=1;i<51;i++){
  3.     s="SS."+i;
  4.     getField(s).value="Yes"
  5. }
Feb 6 '08 #12

acoder
Expert Mod 15k+
P: 16,027
Expand|Select|Wrap|Line Numbers
  1. var s="";
  2. for(var i=1;i<51;i++){
  3.     s="SS."+i;
  4.     getField(s).checked=true;
  5. }
Feb 7 '08 #13

kcdoell
100+
P: 230
Thanks, I tried that with still the same none action response when I click on my "select All" button. This one should be easier. I have been scouting around on the web for solutions but to no avail, just ideas to look into a 500 + page adobe javascript manual.... which does not specifically address what I am trying to accomplish.

Anymore ideas let me know.

Take care,

Keith.
Feb 7 '08 #14

acoder
Expert Mod 15k+
P: 16,027
So the problem is getting this to work on clicking the button? Can you check a checkbox using code without clicking the button?
Feb 8 '08 #15

kcdoell
100+
P: 230
The only way that I can get the checkbox to have a check is to click on it manually.
Feb 8 '08 #16

acoder
Expert Mod 15k+
P: 16,027
So you have two problems. What I suggest is try getting a checkbox checked using JavaScript first and then worry about getting it to work on clicking a button.

Also try an alert popup to test that you can run code when a button is clicked.
Feb 8 '08 #17

kcdoell
100+
P: 230
Hello:

I am a Newbie at JavaScript so please be patient and kind. I am currently creating a form using Adobe LiveCycle Designer 8.0.

On my form I have a section that displays 50 check boxes representing 50 states in the USA. On my form it is reasonable that a end user could select some or all of the states. To that end, I want to have a checkbox or button that will select and deselect all of the State checkboxes. So far I have added a button called "Select All" and on the click event I wrote the following script:

Expand|Select|Wrap|Line Numbers
  1. xfa.form.topmostSubform.Page2.CKSS_AL.rawValue=1 
  2. xfa.form.topmostSubform.Page2.CKSS_AK.rawValue=1 
  3. xfa.form.topmostSubform.Page2.CKSS_AR.rawValue=1 
  4. xfa.form.topmostSubform.Page2.CKSS_AZ.rawValue=1 
  5. xfa.form.topmostSubform.Page2.CKSS_CA.rawValue=1 
  6.  
etc.....

As you can see I have named my checkboxes CKSS_AL, CKSS_AK,,,etc…..CKSS_WY.

This works, but I am thinking that there must be a more efficient way of writing this code. So with that said I took an idea to build an array:

Expand|Select|Wrap|Line Numbers
  1. var stateArray = new Array("AL", "AK", "AR"); 
  2. for ( var state in stateArray ) 
  3. var oField = xfa.resolveNode("xfa.topmostSubform.Page2.CKSS_" + stateArray[state]); 
  4. oField.rawValue = 1; 
  5.  
I only did the array for the first 3 states/checkboxes. Then I copied it into the click event of my "SelectAll" button. I received the following error:

oField has no properties
5:XFA:topmostSubform[0]:Page2[0]:SelectAll[0]:click
oField has no properties
5:XFA:topmostSubform[0]:Page2[0]:SelectAll[0]:click

Any ideas what I am missing? I have no idea what these error messages mean to solve....

Thanks,

Keith.
Feb 20 '08 #18

hsriat
Expert 100+
P: 1,654
Hello:

I am a Newbie at JavaScript so please be patient and kind. I am currently creating a form using Adobe LiveCycle Designer 8.0.

On my form I have a section that displays 50 check boxes representing 50 states in the USA. On my form it is reasonable that a end user could select some or all of the states. To that end, I want to have a checkbox or button that will select and deselect all of the State checkboxes. So far I have added a button called "Select All" and on the click event I wrote the following script:

xfa.form.topmostSubform.Page2.CKSS_AL.rawValue=1
xfa.form.topmostSubform.Page2.CKSS_AK.rawValue=1
xfa.form.topmostSubform.Page2.CKSS_AR.rawValue=1
xfa.form.topmostSubform.Page2.CKSS_AZ.rawValue=1
xfa.form.topmostSubform.Page2.CKSS_CA.rawValue=1

etc.....

As you can see I have named my checkboxes CKSS_AL, CKSS_AK,,,etc…..CKSS_WY.

This works, but I am thinking that there must be a more efficient way of writing this code. So with that said I took an idea to build an array:

var stateArray = new Array("AL", "AK", "AR");
for ( var state in stateArray )
{
var oField = xfa.resolveNode("xfa.topmostSubform.Page2.CKSS_" + stateArray[state]);
oField.rawValue = 1;
}

I only did the array for the first 3 states/checkboxes. Then I copied it into the click event of my "SelectAll" button. I received the following error:

oField has no properties
5:XFA:topmostSubform[0]:Page2[0]:SelectAll[0]:click
oField has no properties
5:XFA:topmostSubform[0]:Page2[0]:SelectAll[0]:click

Any ideas what I am missing? I have no idea what these error messages mean to solve....

Thanks,

Keith.

you may use this instead
[html]<input name="all" type="checkbox" onclick="checkAll()"></input>[/html]
Expand|Select|Wrap|Line Numbers
  1. function checkAll() {
  2.   for (var i=0; i<document.formName.elements.length; i++) {
  3.     var e=document.formName.elements[i];
  4.     if ((e.name != 'all') && (e.type=='checkbox'))
  5.     e.checked=document.formName.all.checked;
  6.   }
  7. }
Feb 20 '08 #19

kcdoell
100+
P: 230
Thanks but when I pasted the script into my click event and then went to the preview mode and click on the select all button nothing happen.

Expand|Select|Wrap|Line Numbers
  1. function checkAll() {
  2.   for (var i=0; i<document.formName.elements.length; i++) {
  3.     var e=document.formName.elements[i];
  4.     if ((e.name != 'all') && (e.type=='checkbox'))
  5.     e.checked=document.formName.all.checked;
  6.   }
  7. }
  8.  
I know that the Adobe liveCycle designer has different JavaScript commands than previous versions. Could that be the issue?
Feb 20 '08 #20

kcdoell
100+
P: 230
Okay; to my button called "Select All" on the click event I wrote the following script:

Expand|Select|Wrap|Line Numbers
  1. xfa.form.topmostSubform.Page2.CKSS_AL.rawValue=1 
  2. xfa.form.topmostSubform.Page2.CKSS_AK.rawValue=1 
  3. xfa.form.topmostSubform.Page2.CKSS_AR.rawValue=1 
  4. xfa.form.topmostSubform.Page2.CKSS_AZ.rawValue=1 
  5. xfa.form.topmostSubform.Page2.CKSS_CA.rawValue=1 
  6.  
etc.....

As you can see I have named my checkboxes CKSS_AL, CKSS_AK,,,etc…..CKSS_WY.

This works, but as I mentioned earlier, I am thinking that there must be a more efficient way of writing this code. So with that said I took an idea to build an array:

Expand|Select|Wrap|Line Numbers
  1. var stateArray = new Array("AL", "AK", "AR"); 
  2. for ( var state in stateArray ) 
  3. var oField = xfa.resolveNode("xfa.topmostSubform.Page2.CKSS_" + stateArray[state]); 
  4. oField.rawValue = 1; 
  5.  
I only did the array for the first 3 states/checkboxes. Then I copied it into the click event of my "SelectAll" button. I received the following error:

oField has no properties
5:XFA:topmostSubform[0]:Page2[0]:SelectAll[0]:click
oField has no properties
5:XFA:topmostSubform[0]:Page2[0]:SelectAll[0]:click

Any ideas what I am missing? I have no idea what these error messages mean to solve....

Thanks,

Keith.
Feb 20 '08 #21

kcdoell
100+
P: 230
Got some help and finally got this one solved:

Expand|Select|Wrap|Line Numbers
  1. var stateArray = new Array("AL", "AK", "AR"); 
  2. for ( var state in stateArray ) 
  3. var oField = xfa.resolveNode("xfa.form.topmostSubform.Page2.CKSS_" + stateArray[state]); 
  4. oField.rawValue = 1; 
  5.  
Keith.
Feb 20 '08 #22

kcdoell
100+
P: 230
Got some help from another friend and finally got this one solved:

Expand|Select|Wrap|Line Numbers
  1. var stateArray = new Array("AL", "AK", "AR"); 
  2. for ( var state in stateArray ) 
  3. var oField = xfa.resolveNode("xfa.form.topmostSubform.Page2.CKSS_" + stateArray[state]); 
  4. oField.rawValue = 1; 
  5.  
Keith.
Feb 20 '08 #23

hsriat
Expert 100+
P: 1,654
Got some help from another friend and finally got this one solved:

var stateArray = new Array("AL", "AK", "AR");
for ( var state in stateArray )
{
var oField = xfa.resolveNode("xfa.form.topmostSubform.Page2.CKS S_" + stateArray[state]);
oField.rawValue = 1;
}

Keith.
Buddy, you got to change the document and formName to the ones used by you.
I dunno about Adobe thing, I never used it.
Feb 21 '08 #24

acoder
Expert Mod 15k+
P: 16,027
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

MODERATOR.
Feb 21 '08 #25

acoder
Expert Mod 15k+
P: 16,027
Got some help and finally got this one solved:
Maybe I'm missing something, but how is this different from what you posted before?

PS. merged duplicate threads.
Feb 21 '08 #26

kcdoell
100+
P: 230
Maybe I'm missing something, but how is this different from what you posted before?

PS. merged duplicate threads.
Acoder:

My JavaScript before was the following:

Expand|Select|Wrap|Line Numbers
  1. var stateArray = new Array("AL", "AK", "AR"); 
  2. for ( var state in stateArray ) 
  3. var oField = xfa.resolveNode("xfa.topmostSubform.Page2.CKSS_" + stateArray[state]); 
  4. oField.rawValue = 1; 
  5. }
  6.  
all that was missing was a the word "form."

The end solutions was the following:

Expand|Select|Wrap|Line Numbers
  1. var stateArray = new Array("AL", "AK", "AR"); 
  2. for ( var state in stateArray ) 
  3. var oField = xfa.resolveNode("xfa.form.topmostSubform.Page2.CKSS_" + stateArray[state]); 
  4. oField.rawValue = 1; 
  5. }
  6.  
Take care,

Like I had mentioned before, my knowledge on Javascript is limited but it appears that the problem was path related.

Keith.
Feb 27 '08 #27

acoder
Expert Mod 15k+
P: 16,027
all that was missing was a the word "form."
Oh right, so it was. Thanks for posting and glad you got it working.

JavaScript on Adobe PDF can be difficult if you're used to the normal standard JavaScript.
Feb 28 '08 #28

Post your reply

Sign in to post your reply or Sign up for a free account.