Multi-select check box with repeating table contro - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Multi-select check box with repeating table contro

Last post 02-15-2005 10:09 AM by rrs. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 02-10-2005 04:58 PM

    • rrs
    • Not Ranked
    • Joined on 02-10-2005
    • USA
    • Posts 5

    Multi-select check box with repeating table contro

    My requirement is as follows:

    Have a list of all offices as check box and the first 2 check box is defined as "All" and "International Offices" and the rest are all defined as "Washington","New York" etc.

    I should be able to select all the offices automatically when I click "ALL" and when I click "International Offices" I should be able to select all international offices.

    I had a repeating table control and check box as a field. I added the values by clicking the Tools/Default value and chose the Group to add values into the repeating table.

    Is it possible to loop through the repeating table (like nodes ) using the validate event and select the rest of the fields dynamically based on "All"/ "Intl. offices" selected.

    Hope I am making sense. Please let me know if its possible.

    Thanks a ton!

    Rajesh
  • 02-11-2005 12:32 PM In reply to

    Re: Multi-select check box with repeating table contro

    First off, during the OnValidate event, the DOM is read-only... so you must do this with the OnAfterChange event.

    Secondly, so long as there is some metadata on each node to identify it as International or not, then you can do what you want.

    OnAfterChange for the ALL check box would walk through each node and check it if it is not already checked.

    OnAfterChange for the International check box would walk through each node and first see if it is "International", and if so, then check it if it is not already checked.

    Greg Collins [InfoPath MVP]
  • 02-14-2005 11:37 AM In reply to

    • rrs
    • Not Ranked
    • Joined on 02-10-2005
    • USA
    • Posts 5

    Re: Multi-select check box with repeating table contro

    I am having problem in setting the check box value. I was able to loop thru all the value but having trouble is setting the specific node. Please see code below.


    if( eventObj.Operation == "Insert" )
    {
    if ((eventObj.Site.selectSingleNode( "../my:officeSelected").text == "true") && (eventObj.Site.selectSingleNode( "../my:officeSelectedText").text == "All"))
    {
    var items = XDocument.DOM.selectNodes("/my:myFields/my:officesAffected/my:officeAffected");
    for (var i=0;i<items.length;i++)
    {
    XDocument.UI.Alert(items(i).text);
    // this is where I am confused.
    }
    }
    }


    Thanks a lot.
  • 02-15-2005 07:15 AM In reply to

    Re: Multi-select check box with repeating table contro

    I don't know exactly what your schema looks like, so I'm taking a stab in the dark here...

    It looks like you are trying to perform the "ALL" functionality in this code. You don't want to waste time selecting a check box that is already selected, so you only want to get those that are not selected. So the XPath might look something like:

    selectNodes("/my:myFields/my:officesAffected/my:OfficeAffected[. != 'true']")

    Once you have your collection of unselected check boxes, then you just loop through them as you are doing and set their value as selected:

    items(i).text = "true"

    Greg Collins [InfoPath MVP]
  • 02-15-2005 10:09 AM In reply to

    • rrs
    • Not Ranked
    • Joined on 02-10-2005
    • USA
    • Posts 5

    Re: Multi-select check box with repeating table contro

    Awesome. Thanks a lot Greg. It worked.
    The following is the javascript function. This applies only when you check the "All" office check-box.

    function msoxd_my_officeSelected::OnAfterChange(eventObj)
    {
    if( eventObj.Operation == "Insert" )
    {

    //XDocument.UI.Alert(eventObj.Site.selectSingleNode( "../my:officeSelectedText").text);

    // if all offices are checked.
    if ((eventObj.Site.selectSingleNode( "../my:officeSelected").text == "true") && (eventObj.Site.selectSingleNode( "../my:officeSelectedText").text == "All"))
    {
    var items = XDocument.DOM.selectNodes("/my:myFields/my:officesAffected/my:officeAffected/my:officeSelected[. != 'true']")

    for (var i=0;i<items.length;i++)
    {
    items(i).text = "true"
    }
    }
    }
    }

    Thanks
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.