A button to select all checkboxes.

J

John R

I am looking at creating a button with the tag Select All that once it
is pressed it will select all the checkboxes on the form. I went
through setting rules and conditions with no luck. Thinking the only
way to do this is by writting a script. I have a list of checkboxes
with the MS1 - MS7 and a button Select All. The programming language on
the form is set to VBScript. Any help in the right direction would be
great, thanks.
 
T

tommcd24

John said:
I am looking at creating a button with the tag Select All that once it
is pressed it will select all the checkboxes on the form. I went
through setting rules and conditions with no luck. Thinking the only
way to do this is by writting a script. I have a list of checkboxes
with the MS1 - MS7 and a button Select All. The programming language on
the form is set to VBScript. Any help in the right direction would be
great, thanks.


I'm new to InfoPath, so I'm not sure on the XPath, etc. to direct the
script down to the right node, but the code to check the checkbox would
be something to the effect of

MS1.checked = True
MS2.checked = True
.... etc.

assuming the MS1 - MS7 is the ID of your checkboxes. The code would
need to be placed in the btnSelectAll_Click method.

Hope that helps!
 
J

John

I am also new to Infopath, and it looks like I am going in the right
direction. The Field Name for the checkboxes are MS1 - MS7 with a
button ID btnSA1. What I been playing with is similar to what you said.

Sub btnSA1_OnClick(eventObj)
MS1.checked = True
MS2.checked = True
MS3.checked = True
MS4.checked = True
MS5.checked = True
MS6.checked = True
MS7.checked = True
End Sub

What would the XPath look like get to the Node if the setup look like
this?

myFields
MainForm
btnSA1
MS1
MS3
MS4
MS5
etc...

Thanks
 
J

John

Another note: I dont have to do this in VBScript. If you know a way to
do it using JScript feel free to comment. I can do both languages.
function btnSA1::OnClick(eventObj)
{
}
Thanks
 
J

John

I am getting close to figuring it out. Now what I am getting is it
selects the checkboxes but it is putting a red box around them instead
of putting a check mark in the box.

Example:
XDocument.DOM.selectSingleNode("/my:myFields/my:MainForm/my:MS1").text
= true

If I do .value instead of .text I get an error "Object doesn't supprt
this property or method".

Am I on the right track and if so what am I missing to make this work
correctly?
John
 
S

S.Y.M. Wong-A-Ton

Just wondering why rules did not work for you. If you add a rule to the
button that says: Set a field's value, with the field being a checkbox, and
its value being true(), then the checkbox is checked when you click the
button.
 
S

S.Y.M. Wong-A-Ton

Yes, you are close indeed. Make true a string and you should be fine. In
JScript:

XDocument.DOM.selectSingleNode("<xpath_to_checkbox>").text = "true";
 
J

John

I did try through the rules and for some reason I wasnt able to get it
to work. I can beleive all i was missing was the " " around true to
get it to work. I thought I tried that but I was trying so many things
I couldnt remmeber what I tried and what I didnt.

Thanks,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top