Add event to Check Box in InfoPath Form - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Add event to Check Box in InfoPath Form

Last post 04-01-2009 11:09 AM by JeffTangen. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 03-26-2009 04:34 PM

    Add event to Check Box in InfoPath Form

    I was wondering is anyone has had experience adding an event to a check box.  I have a form with 2 repeating tables in a Parent/Child arrangement.  If a certain check box called "No Show" is checked I want all the rows in the "Current" rows child table removed.  The following article talks about a button but the code cannot handle nested repeating tables.  It uses /my:myFields/my:group1/my:group2 (my:group2 is a repeating table.)  I want to do /my:myFields/my:group1/my:group2/my:group3 (where my:group2 and my:group3 are both repeating tables.)

     http://www.bizsupportonline.net/infopath2007/programmatically-delete-all-rows-repeating-table-infopath.htm

     

  • 03-27-2009 12:58 AM In reply to

    Re: Add event to Check Box in InfoPath Form

    The title and first sentence of your post really have almost nothing to do with your actual question, and it doesn't really make sense to me to use a checkbox instead of a button for this purpose.  Having a checkbox that says "No Show" and deleting the entire group instead of hiding it is misleading.

     Nonetheless, if you were to use a checkbox, and the checkbox's field were a child of my:group2, the code would be something like this:

    if (e.NewValue == "true")
    {
         XPathNavigator group2 = e.Site.SelectSingleNode("..", NamespaceManager);

         string myNamespace = NamespaceManager.LookupNamespace("my");
         while (group2.MoveToChild("group3", myNamespace))
         {
              group2.DeleteSelf();
         }
    }

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 03-27-2009 08:37 AM In reply to

    Re: Add event to Check Box in InfoPath Form

    Thanks for the input.  I don't want the group2 row deleted, just the group 3 row below it.  Below is a screen shot of the form.  This is a documentation we use to bill for patients.  Group2 is in a Master/Detail control. The Patient List is the "Master" and the check marks above Procedure are the "Details".  The row that begins with procedure (I circled with Black) is a blank row that infopath always creates and wants to submit to the database.  I want this row removed if the patient is a canelation (CX), Reschedule (RS), or a No Show (NS).  I don't want to remove the CX, RS, or NS Check Box info just the rows in the child table.  

    ChargeSheetForm

  • 03-31-2009 11:09 AM In reply to

    Re: Add event to Check Box in InfoPath Form

    I still can't get this right. 

    1. Here is my real xpath:   /my:myFields/my:Charges/my:ChargeDetails
    2. Here is the function I am trying to get to work.  It is in script.js.  I am no programmer but I think it needs to be javascript.  It needs to be able to open in Infopath 2003.  I got rid of the delete self because I don't want the row in "Charges" deleted just "ChargeDetails".

     

    function msoxd_my_Cancellation::OnAfterChange(eventObj)
    {
     if (eventObj.IsUndoRedo)
     {
      {
         XPathNavigator Charges = e.Site.SelectSingleNode("..", NamespaceManager);
         string myNamespace = NamespaceManager.LookupNamespace("my");
         while (Charges.MoveToChild("ChargeDetails", myNamespace))
                 }
      return;      
     }
    }

     

    Any help will be appreciated..

  • 03-31-2009 11:46 AM In reply to

    Hi, Jeff:

    The code sample Jimmy posted was C# for the 2007 InfoPath model. I'm attaching a sample form that has jscript on the after change event for a checkbox that then removes a repeating group....

    Right click on the link in the heading of this post and Save As to get the file. Then you can open in design mode and preview to test it. You'll be able to look at the script file as well, to see how it works. Let us know if you need more help!

    Hilary Stoupa

  • 04-01-2009 08:10 AM In reply to

    Re: Add event to Check Box in InfoPath Form

    Hi Hilary.  Thanks for the help.  I almost got it to work.  The only diference is that Charges also repeats.  The script works on the first charge but not the second or higher charge.  I think the script needs to know which charge it is in.  Thank you so  much for the sample.  It helped me understand where the script should be placed and the format.

     

    1. Charges is in a Master/Details format.

    2. ChargeDetails is a child of Charges.

  • 04-01-2009 08:33 AM In reply to

    Please try this modified version of Hilary's form.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-01-2009 08:39 AM In reply to

    Hi, Jeff -- see attached template. I modified my schema and the code. Let me know if you need more info, okay?

    Hilary Stoupa

  • 04-01-2009 11:09 AM In reply to

    Re: Add event to Check Box in InfoPath Form

    Thanks you two.  It works awesome!!!

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