Change value of field based on drop down selection - InfoPath Dev
in

InfoPath Dev

Change value of field based on drop down selection

Last post 05-24-2007 10:31 AM by Greg Collins. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 12-21-2004 04:54 AM

    Change value of field based on drop down selection

    I have been working for quite some time on trying to set the value of a field based on the selection of a drop-down list. First off, there seem to be several different ways (none documented well at all) on how this should be accomplished.

    I have a table in a SQL Server database that has an id, name, and email address. I have the names showing up in a drop down list. When someone selects the name, I want the email field populated automatically.

    I have tried writing code by opening the script editor but this is painful and debugging is impossible. I have tried using the "rules" and filters but that doesn't seem to work.

    I found the Examples on this site and thought I had found some help. Unfortunately, I don't have the Northwind database installed so I can't even open the example that I thought would help. No commentary accompanied the example so that didn't help.

    I have done countless google searches but I cannot seem to find relevant answers. Do I sound frustrated? I am.
  • 12-21-2004 11:00 AM In reply to

    Re: Change value of field based on drop down selection

    Let's assume your drop-down list displays "name" and stores "id", and is bound to "field1". Let's also assume you want to populate "field2" with "email" when the drop-down value changes.

    Let's assume you have a secondary data source named "sql" with a repeating list of "person"s that you are getting the values from.

    You will use rules and filters such that:

    Rule on "field1" =
    Set value of "field2" to be "sql/person/email[../id = (MainDOM)/field1]"

    Greg Collins [InfoPath MVP]
  • 12-21-2004 11:12 AM In reply to

    Re: Change value of field based on drop down selection

    1) create two sections. (not repeating sections, just plain sections)

    2) Put a drop down list box in the first section and bind it to the query field that holds the ID (it should be under q:TableName)

    3) Put a text box in the second section and bind it to the data field that holds the email address (should be under d:TableName)

    4) Right click the drop down list box, choose drop down list box properties, then click the "Rules" button. Click "Add a rule", then click "Add an action", and then choose the "Query using a data connection" action with the main data connection.

    Now when you change the drop down selection, the email text bopx should get populated.


    **Note: your drop down list box should be bound to the ID query field in the main data source, but it can get its list box entries from another source (I would create a secondary data source with the same table that is used in the main data connection, then populate the drop down using that connection)
  • 05-18-2007 01:12 PM In reply to

    Re: Change value of field based on drop down selection

    In your example....  sql is the name of the data source, person is the name of the table, and email is the name of the column?  I cannot seem to get this working with my system.

     Are the quotes necessary and is the equals sign listed right after the "field 1" part of anything?

     Does the ../ mean to go back a level in the data source hierarchy?

     

    I greatly appreciate your help.

    - Tim

  • 05-24-2007 10:31 AM In reply to

    Re: Change value of field based on drop down selection

    Your first question -- yes, those assumptions are correct.

    Quotes are there to separate the code from the rest of the text.

    The equal sign after field1 stands for "is defined as".

    The ../ means to go to the parent node.

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.