Adding with jscript items to a listbox - InfoPath Dev
in

InfoPath Dev

Adding with jscript items to a listbox

Last post 03-13-2006 11:39 AM by fredarwin. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-10-2006 07:06 AM

    Adding with jscript items to a listbox

    Hi,

    How to insert a new item Programmatically to a lisbox from a button click for example?

    i got this, for example:

    var oToList=
    XDocument.DOM.selectSingleNode("//dfs:myFields/my:Asisten");
    var oToItem=
    XDocument.DOM.selectSingleNode("//dfs:myFields/my:Asisten/my:Name");

    var oFromItem= "XData";

    oToList.insertBefore(oFromItem, oToItem);

    But, it doesn´t work. Maybe i need another way to do this.
    Any Help?
  • 03-11-2006 05:27 AM In reply to

    Re: Adding with jscript items to a listbox

    Hi Fred,
    Change your last two lines of code to the following then it should work,
    var oFromItem = oToItem.CloneNode(false);
    oFromItem.text = "XData";
    oToList.insertBefore(oFromItem, oToItem);

    Mistake you did was to add string value as a node.
  • 03-13-2006 06:21 AM In reply to

    Re: Adding with jscript items to a listbox

    Thanx Agni,

    But, I have a question,
    to using insertBefore:
    oToList.insertBefore(oFromItem, oToItem);

    oToItem need to be a repeating node?
  • 03-13-2006 11:39 AM In reply to

    Re: Adding with jscript items to a listbox

    I got it!!!.

    solution:

    var row = XDocument.DOM.selectSingleNode("//my:Asisten2");
    var doc = XDocument.DataObjects("UsersAD").DOM
    doc.setProperty("SelectionNamespaces",
    'xmlns:q="http://schemas.microsoft.com/office/infopath/2003/ado/queryFields" ' +
    'xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" ' +
    'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"');

    var oFromItem = XDocument.DOM.selectSingleNode("//dfs:myFields/my:Asisten/my:Nombre");
    var selectedNode=doc.selectSingleNode("/dfs:myFields/dfs:dataFields/d:vUsersAD[@idusersAD='" + oFromItem.text + "']")

    row = row.cloneNode(true);
    row.selectSingleNode("my:idnombre").text = oFromItem.text;
    row.selectSingleNode("my:Nombre2").text = selectedNode.attributes.getNamedItem("NombreCompleto").text;

    var parent = XDocument.DOM.selectSingleNode("//dfs:myFields");
    parent.appendChild(row);
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.