Populating repeating table rows with same value - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Populating repeating table rows with same value

Last post 02-11-2005 12:34 PM by Greg Collins. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 02-08-2005 12:31 PM

    Populating repeating table rows with same value

    Using Jscript I can populate a field value based off a value into another field. When using Repeating tables I can only populate the first row in the table. I am assuming that I have to loop through the rows but am having issues.
    I have a field where a user enters their name "EnterName" and then I want to populated the "grp_field" that is within a repeating table.

    The code (feeble code attempt) below will work for the top field but not any additional rows.

    {
    var EnterName = XDocument.DOM.selectSingleNode("//my:EnterName");
    var SetField6 = XDocument.DOM.selectSingleNode("//my:group/my:small_grp/my:grp_field");
    SetField6.text = EnterName.text
    }


    Please let me know if you have any ideas!

    Thanks,
    Brian
  • 02-08-2005 04:35 PM In reply to

    Re: Populating repeating table rows with same value

    If you want the value in each row to change when the name field changes, then yes, you will need to loop through each row.

    {
    var oEnterName = XDocument.DOM.selectSingleNode("//my:EnterName");
    var oNodes = XDocument.DOM.selectNodes("//my:group/my:small_grp/my:grp_field");
    var oNode;
    while(oNode = oNodes.nextNode())
    {
    oNode.text = EnterName.text;
    }
    }


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

    Re: Populating repeating table rows with same value

    Greg, Thanks a ton!
    One last question if you don't mind. Now with that same bit of functionality, how could I update the "grp_field" when it has a specific value that exists in it already. Like I set a default value of "update" and then I only want to populate the "grp_field" with the "EnterName" field value when the text of "update" is already in the "grp_field". Or a blank value which might be expressed as "" ?

    I probably just need know where to put the If statement. Something like If oNode.text = "update" then oNode.text = oEnterName.text.

    I will try to figure this out today but I figured I would ask since you could probably do it in 15 seconds.

    Thanks again for your help!
    Brian
  • 02-10-2005 12:31 PM In reply to

    Re: Populating repeating table rows with same value

    You just need to specify a filter in the XPath you are selecting... as follows:
    {
    var oEnterName = XDocument.DOM.selectSingleNode("//my:EnterName");
    var oNodes = XDocument.DOM.selectNodes("//my:group/my:small_grp/my:grp_field[. = 'update' or . = '']");
    var oNode;
    while(oNode = oNodes.nextNode())
    {
    oNode.text = EnterName.text;
    }
    }


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

    Re: Populating repeating table rows with same value

    Thanks! I actually got it to work yesterday by using something like
    {
    var oEnterName = XDocument.DOM.selectSingleNode("//my:grp1/my:EnterName");
    var oNodes = XDocument.DOM.selectNodes("//my:Acq_grp/my:Acq_nxt_grp/my:acq_nxt_usr");
    var oNode;
    while(oNode = oNodes.nextNode())
    {
    if (oNode.text == "-")
    oNode.text = oEnterName.text;
    }
    }

    Thanks for your help!!
    I like your site especially since there didn't used to be many InfoPath online resources!
    Brian
  • 02-11-2005 12:34 PM In reply to

    Re: Populating repeating table rows with same value

    Thanx much!
    Glad you got it working!
    Glad to be able to help out.

    Greg Collins [InfoPath MVP]
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.