Use check box to populate a Repeating Table - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Use check box to populate a Repeating Table

Last post 11-18-2005 06:42 AM by Matt Faus. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 11-14-2005 12:55 PM

    Use check box to populate a Repeating Table

    I have a form with several check boxes (50-100) and a repeating table on a second view. I want the user to check the check boxes which will populate a text box in a repeating table i.e like a list. I have seen several posts relating to this but I need a few things clarified if possible:

    Two questions

    1. Will I need to write code on every check box?
    2. Is there a way to do this without writing code via rules?

    Thanks
    Smitty
  • 11-14-2005 02:37 PM In reply to

    Re: Use check box to populate a Repeating Table

    Hi,

    It is unlikely that you can handle the logic behind 100 checkboxes with rules (+ it may hit your form performance). The easiest way is to write code. Now, depending on what you are trying to do, you could build your schema so that all checkboxes are in one folder. Next you can catch the OnAfterChange event at that folder level. This way, as soon as 1 of the 100 checkboxes are clicked, you will be able to manipulate the event to populate your textboxes based on which box was checked/unchecked.

    Regards,

    Franck Dauché
  • 11-15-2005 11:22 AM In reply to

    Re: Use check box to populate a Repeating Table

    Thanks Franck

    Any idea where I can get some sample vbscript or vb.net code to try.

    Thanks again
    Smitty
  • 11-15-2005 11:02 PM In reply to

    Re: Use check box to populate a Repeating Table

    How about our book?
    :)

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 11-16-2005 06:54 AM In reply to

    • Rip
    • Not Ranked
    • Joined on 02-04-2005
    • USA
    • Posts 20

    Re: Use check box to populate a Repeating Table

    I am trying to do something similar but I want to include a confirm dialog box to allow the user to cancel the population if they change their mind. What should happen is the user checks a check box and a number of text boxes are filled with "0". If they uncheck the box the fields should be empty. I am having trouble getting this work correctly. I have your book Patrick so if there is a section in it that will help please point me in that direction.

    Richard T. Henry
    Lewisberry, PA, USA
    riphenry@gmail.com
  • 11-16-2005 07:06 AM In reply to

    Re: Use check box to populate a Repeating Table

    Hi Richard,

    In your OnBeforeChange event (the global one triggered for all checkboxes), prompt the users and to cancel the event if needed use:
    e.ReturnStatus = False

    Regards,

    Franck Dauché
    InfoPathDev
  • 11-16-2005 07:20 AM In reply to

    Re: Use check box to populate a Repeating Table

    This is a pretty late response to mdsmitty, but in this specific case instead of using an OnAfterChange() on the checkbox folder you could use OnSwitchView(). This way instead of processing the checkboxes with every click you do it just once (maybe slight performance gain?). Also, you don't have to worry about depopulating your list on an uncheck, you only have to generate the list once when the views are changed.

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 11-16-2005 08:09 AM In reply to

    • Rip
    • Not Ranked
    • Joined on 02-04-2005
    • USA
    • Posts 20

    Re: Use check box to populate a Repeating Table

    quote:
    Originally posted by franck

    Hi Richard,

    In your OnBeforeChange event (the global one triggered for all checkboxes), prompt the users and to cancel the event if needed use:
    e.ReturnStatus = False

    Regards,

    Franck Dauché
    InfoPathDev



    Franck,
    I am not sure I understand how to do this. I am including a simple sample of what code I have. I have a check box named checkall and two text boxes; dataone and datatwo. If the checkbox is checked dataone and datatwo have 0 inserted. If unchecked blank inserted. Each time the status of the checkbox checkall is changed I want a confirm box to popup. Thanks for any direction you can provide.

    Rip

    Code Sample:


    function msoxd_my_checkall::OnBeforeChange(eventObj)
    {
    // Write your code here
    // Warning: ensure that the constraint you are enforcing is compatible with the default value you set for this XML node.
    if (eventObj.Operation == "Insert"){
    var mychoice = XDocument.UI.Confirm("Update Fields?", 1);
    if (mychoice == 2){
    e.ReturnStatus = False;
    }
    }

    }


    function msoxd_my_checkall::OnAfterChange(eventObj)
    {
    // Write code here to restore the global state.

    if (eventObj.IsUndoRedo)
    {
    // An undo or redo operation has occurred and the DOM is read-only.
    return;
    }

    // A field change has occurred and the DOM is writable. Write code here to respond to the changes.
    if (eventObj.Operation == "Insert"){

    var myzero = "0";
    var myblank = "";

    if (eventObj.Site.selectSingleNode("../my:checkall").text == "true"){
    //Checkbox Unchecked
    XDocument.DOM.selectSingleNode("//my:dataone").text = myzero;
    XDocument.DOM.selectSingleNode("//my:datatwo").text = myzero;

    }else{
    //Checkbox Unchecked
    XDocument.DOM.selectSingleNode("//my:dataone").text = myblank;
    XDocument.DOM.selectSingleNode("//my:datatwo").text = myblank;
    }

    }

    }

    Richard T. Henry
    Lewisberry, PA, USA
    riphenry@gmail.com
  • 11-16-2005 08:44 AM In reply to

    Re: Use check box to populate a Repeating Table

    Hi Richard,

    Earlier, you mentioned VBScript or VB.Net, the line I gave you is VB.Net.
    You posted JScript. In that case, the event is "eventObj", not "e".

    Regards,

    Franck Dauché
    InfoPathDev
  • 11-18-2005 06:21 AM In reply to

    Re: Use check box to populate a Repeating Table

    Matt,

    Thanks for the response...that sounds like an easier method and a perspective that I haven't thought of. Developement can give you a bad case of tunnel vision from time to time. That seems like a better angle of attack. I will look into it and let you know how it goes.

    Thanks again
    Smitty
  • 11-18-2005 06:42 AM In reply to

    Re: Use check box to populate a Repeating Table

    No problem - good luck!

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (11 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.