Drop Down List 2nd value - InfoPath Dev
in

InfoPath Dev

Drop Down List 2nd value

Last post 12-01-2006 01:21 AM by Alien1983. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 11-24-2006 06:17 AM

    Drop Down List 2nd value

    Hello

    I need to display the 2nd value of my drop down list.

    This displays the FIRST value of my list:
    -----------------------------------------
    Dim myList As IXMLDOMNode
    myList = thisXDocument.DOM.selectSingleNode("my:myFields/my:test")
    textField.text = myList.text


    This also displays the FIRST value of my list:
    -----------------------------------------
    Dim myList As IXMLDOMNodeList
    myList = thisXDocument.DOM.selectNodes("my:myFields/my:test")
    textField.text = lista(0).text


    BUT.....

    This DOESN't displays the SECOND value of my list :(
    -----------------------------------------------------
    Dim myList As IXMLDOMNodeList
    myList = thisXDocument.DOM.selectNodes("my:myFields/my:test")
    textField.text = lista(1).text


    This gives me an error:

    System.NullReferenceException
    Object reference not set to an instance of an object.

    How can I display the second value of my list? Any suggestions?

    PS. I don't want to use XPath because I need to do some operations directly from my VB code.
  • 11-24-2006 06:24 AM In reply to

    Re: Drop Down List 2nd value

    Of course lista = myList, I made some translation mistakes.


    Dim myList As IXMLDOMNodeList
    myList = thisXDocument.DOM.selectNodes("my:myFields/my:test")
    textField.text = myList(1).text


    Generally I need a reference to n element of my list.

    I would be greatful if you could help.
  • 11-24-2006 10:21 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: Drop Down List 2nd value

    Hi Alien Welcome to the Forums,

    Can you check in your list (myList) once how many nodes it returns and that is you expected answer or not. Some times it will return “/n/t” also consider as nodes.
    If ‘myList#%92 is repeated nodes it returns some length. In debug mode you can get the length of the myList using ‘myList.length#%92 and it will return integer value.

    If you have list of nodes in ‘myList#%92 node list, then you can write the below code to get the second node value.

    //Check the node length is more than zero or not
    If(myList.length > 0)
    {
    //Get the second node
    IXMLDOMNode secondNode = myList[1];
    //Get the second node value
    var nodeValue = secondNode.text;
    }
  • 11-26-2006 01:20 AM In reply to

    Re: Drop Down List 2nd value

    Thanks for your reply

    The interesting thing is that length of my list = 1 but my list consist of for example 5 elements. I populate my list by manually enter values in Properties of my list. On the preview there are all elements but length still = 1. Why? :(

    Set myList = XDocument.DOM.selectNodes("/my:mojePola/my:pole1")
    Set textField = XDocument.DOM.selectSingleNode("/my:mojePola/my:pole2")
    textField.text = myList.length


    // textField.text, gives me 1

    PS. The list is not repeatable, this is simple list and there are for example 5 values:
    aa, bb, cc, dd, ee
  • 11-27-2006 06:59 AM In reply to

    Re: Drop Down List 2nd value

    Can someone help me/us? I noticed that there is a similar thread Dropdown Lists by michael.knowles. I also need to find the max value of my list but my list consist of strings. I need to do some parse operations first and then find max, so I need a reference to any element of my list.

    Please help :)
  • 11-28-2006 02:37 AM In reply to

    Re: Drop Down List 2nd value

    Hi Aliena1983,

    If you manually populate the values of the dropdown there is no way to programatically access them. The reason the NodeList that you are getting has a length of one is because you are getting the value of the current selection in the drop-down, not the list of possible values. What you will have to do is move the possible values to a secondary DOM, or a repeating node in your main DOM.

    Moving the selections in the dropdown to a secondary DOM has been discussed many times on the forum.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 12-01-2006 01:21 AM In reply to

    Re: Drop Down List 2nd value

    Thanks, I'll try with DOM :)
Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.