get Display Name from ddl box thats done manually - InfoPath Dev
in

InfoPath Dev

get Display Name from ddl box thats done manually

Last post 10-19-2007 02:55 AM by jatuphum. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-15-2005 07:51 AM

    get Display Name from ddl box thats done manually

    Hello everyone,

    I need help on just getting the "display name" for a drop down list box and then show it in a textbox. I did search the forum and Greg says to:
    "You can get them by knowing where your drop-down list box is getting its display values. You can, for example, use a rule when the drop-down list changes to go to the source and filter by the selected value to get the selected display name and save that into the text box field."

    Most of the examples show where the drop down list box comes from a secondary data source (xml file or web services), but in my example i am listing the fields Manually. I was trying to filter the "Value" in the drop down list box, but I don't know what I'm supposed to filter by? I don't quite understand how to do this. I think it's something basic, but I can't figure it out.

    Anybody knows the answer, please let me know! Thanks..and remember I am filling my drop down list box manually, NOT from a data source.

    Thanks in advance,
  • 11-15-2005 12:01 PM In reply to

    Re: get Display Name from ddl box thats done manually

    Your going to have to link your options on the DDL to a secondary data source to be able to dynamically pull more than one item of information from them - value and display name. It's pretty easy, do this:

    1)Create a brand new blank form in infopath with a repeating table with 2 columns.
    2) Rename the first column "DisplayName" and the second column "Value"
    3) Save the form and open it again for filling out.
    4) Fill out the form with your diplay names and values. Save this form as an XML file.
    5) Go back to your original form with the DDL and import the XML file that you just saved as a data connection. Do this by going to Tools -> Data connections... -> Add.. -> Recieve Data -> XML Document -> Browse, etc. - Now your the information that you just saved in the XML document is linked as a secondary data source (2DS).
    6) Now double-click on your DDL and choose "Look up values in a data connection to a database,... file ..." and choose your 2DS as the data connectioin to use. - Now you have your DDL being populated from the data in the 2DS.

    To get at the "DisplayName" for each one and put it in another textbox or something, you would put a function in the textbox that would use XPath to find the correct node on the 2DS. The XPath would look something like this:

    /SecondaryData/group1/group2[value = dropdown]/DispName


    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 11-15-2005 10:34 PM In reply to

    Re: get Display Name from ddl box thats done manually

    Hi Matt,
    Sweet post. Send me e-mail with your address so I can send you a prize for your 100th post.

    Patrick Halstead [InfoPath MVP]
    InfoPathDev
    Patrick Halstead
    Project Manager at Qdabra
  • 11-16-2005 07:52 AM In reply to

    Re: get Display Name from ddl box thats done manually

    Thanks for the help Matt! I just tried it and it worked. I didn't think about just saving the values into an XML file and creating a data connection for it, but it was a good idea. I have created other XML files to populate ddl's but I didn't do it in this particular case b/c these values will never change. The reason I used XML files for the other cases is b/c the users might change those values. Also kudos for posting the formula, I was able to look at it and then make my Expression box work by filtering based on the 2DS.
    This is what my XPath Expression Box formula looked like:
    XML file had 2 fields. The parent node was called "Info" and the 2 child nodes "DisplayName" and "Value" like how you stated above.

    DisplayName[Value = Type]
    (which says to show the DisplayName in the expression box when the Value in the 2DS equals the value in Type field)

    This is also equivalent to this XPath (Advanced) formula:
    xdXDocument:GetDOM("Contracts")/Contracts/Info/
    DisplayName[../Value = xdXDocument:get-DOM()/my:Type]

    Thanks a bunch,
  • 10-17-2007 01:39 AM In reply to

    Re: get Display Name from ddl box thats done manually

    Hi,

    I want to know, Can this solution operate with Browser-Form?

    And How to?

    Cheers.

    インフォパス ● デべロッパー
  • 10-19-2007 02:55 AM In reply to

    Re: get Display Name from ddl box thats done manually

    Hi Matt,

    I don't understand "/SecondaryData/group1/group2[value = dropdown]/DispName"

    This is my XML File this I set to Secondary Datasource named "LeaveInfo".

    <?xml version="1.0" encoding="utf-8"?>
    <LeaveInfo>
     <Leaves>
      <Leave>
       <Value>1</Value>
       <DisplayName>Annual Leave</DisplayName>
      </Leave>
      <Leave>
       <Value>4</Value>
       <DisplayName>CTO</DisplayName>
      </Leave>
      <Leave>
       <Value>2</Value>
       <DisplayName>Sick Leave</DisplayName>
      </Leave>
      <Leave>
       <Value>3</Value>
       <DisplayName>Uncertified Sick Leave</DisplayName>
      </Leave>
     </Leaves>
    </LeaveInfo>

    How I try to set the formula?

    Cheers.

    インフォパス ● デべロッパー
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.