Checkbox Event Within Repeating Section - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Checkbox Event Within Repeating Section

Last post 11-29-2005 01:57 PM by franck. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 11-29-2005 06:24 AM

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

    Checkbox Event Within Repeating Section

    I have a checkbox inside a repeating section. When the checkbox is checked or unchecked I would like a confirmation box to be displayed. Based on the result other fields within the repeating section will be populated or cleared.

    I have everything working with one problem. The OnBeforeChange event is fired not only when the checkbox is changed but also when a new repeating section is added. How do I differentiate between a checkbox change and a repeating section insertion? An code example is shown below. Thanks for all the assistance.

    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){
    eventObj.ReturnMessage = "Update Canceled";
    eventObj.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 = "";

    eventObj.Site.selectSingleNode("../my:dataone").removeAttribute("xsi:nil");
    eventObj.Site.selectSingleNode("../my:datatwo").removeAttribute("xsi:nil");

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

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

    }

    }

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

    Re: Checkbox Event Within Repeating Section

    Hi Richard,

    Just a thought here: look into comparing the OldValue and NewValue of your event in your OnBeforeChange. If you chaged the value, OldValue will be different than NewValue, but on Insert, both may be identical.
    Let me know if that works.

    Regards,

    Franck Dauché
    InfoPathDev
  • 11-29-2005 09:20 AM In reply to

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

    Re: Checkbox Event Within Repeating Section

    I am not sure I understand what values you are talking about here.

    Richard T. Henry
    Lewisberry, PA, USA
    riphenry@gmail.com
  • 11-29-2005 09:40 AM In reply to

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

    Re: Checkbox Event Within Repeating Section

    Franck... I figured out the following solution:

    In the onBeforeChange function change the if statement to

    if (eventObj.Operation == "Insert" && eventObj.NewValue != null){


    Richard T. Henry
    Lewisberry, PA, USA
    riphenry@gmail.com
  • 11-29-2005 01:57 PM In reply to

    Re: Checkbox Event Within Repeating Section

    Glad you got it to work.

    Regards,

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