JScript Copy & Paste Section - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

JScript Copy & Paste Section

Last post 04-13-2007 01:29 AM by B.Shiva Prasad. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-11-2007 03:19 AM

    • edove
    • Top 500 Contributor
    • Joined on 08-21-2006
    • Posts 50

    JScript Copy & Paste Section

    I have a section on an infopath form and I would like to use jscript to copy the section and paste it to somewhere else in the form. A rich text field for example.

    I know I can use the section menu to copy and paste but I want to do it with code when the user presses a button. Can anyone help?

    I thought maybe I could use ExecuteAction to do it, but not sure how.
  • 04-11-2007 06:16 AM In reply to

    Re: JScript Copy & Paste Section

    Hi edove

    you need to add a button and write code on 'OnClick function'

    function CTRL1_5::OnClick(eventObj)
    {
    var group1Node = XDocument.DOM.selectSingleNode("<Xpath of Source section>");
    var group2Node = XDocument.DOM.selectSingleNode("<Xpath of destination section>");

    group2Node.selectSingleNode("<my:field1 name in destination section>").text = group1Node.selectSingleNode("<my:field1 name in source section>").text;
    .
    .
    .
    }

    you have to write selectSigleNode code line for all the fields present in a section.
    When the destination section is in different view then add this code line in 'OnClick function first and then write the above code

    XDocument.View.SwitchView("view2");
    Madhuri
    http://www.ggktech.com
  • 04-11-2007 06:22 AM In reply to

    • edove
    • Top 500 Contributor
    • Joined on 08-21-2006
    • Posts 50

    Re: JScript Copy &amp; Paste Section

    Hi.

    Thanks but I really need to copy the whole table or even the whole section in one go.

    I maybe need to explain a bit better..

    I have an optional section. Inside that section is a table. One row of the table contains static values, the row beneath contains a repeating table.

    Users are going to add additional rows to the repeating table, fill out all of the fields and at some point I want them to be able to click a button and copy the whole section into another view. It can be into a rich text field.

    I know that I can do this by going to the optional section, clicking on the arrow and selecting "copy", then paste it into the field but I want this to happen automatically.
  • 04-13-2007 01:29 AM In reply to

    Re: JScript Copy &amp; Paste Section

    Hi edove,

    try this logic, Take the node of the section and create a DOM with that.Take the DOM in another view and traverse the DOM to child nodes and take the values of the nodes and paste it in what ever the fields you required.

    Hope this will help you.

    If you still have problem, Please let me know.
    B.Shiva Prasad
    InfoPath Dev,
    http://www.ggktech.com
    India
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.