Changing a Drop-Down List box's Entries, value and display name values using code - InfoPath Dev
in

InfoPath Dev

Changing a Drop-Down List box's Entries, value and display name values using code

Last post 03-25-2008 04:28 PM by Greg Collins. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-25-2008 03:06 PM

    Changing a Drop-Down List box's Entries, value and display name values using code

    With a drop-down list box which allows the user to select either fruit or veggies, I would like to change the the entries value for a second drop down list to point to the correct group in the following xml file:

    <my:Choices>
     <my:Fruits>
      <my:Fruit>
       <my:Name>Apple</my:Name>
       <my:Name>Peach</my:Name>
       <my:Name>Pear</my:Name>
      </my:Fruit>
     </my:Fruits>
     <my:Veggies>
      <my:Veggie>
       <my:Name>Carrot</my:Name>
       <my:Name>Pea</my:Name>
      </my:Veggie>
     </my:Veggies>
    </my:Choices>

     This a simple example of what I am trying to accomplish but it gets my point across. I know that I can actually change the xml file to a fruit.xml and veggies.xml and change the data source but this is not an option as I do not have control over the xml file with the data I need.

    Thanks for any help!

    Filed under:
  • 03-25-2008 04:28 PM In reply to

    Re: Changing a Drop-Down List box's Entries, value and display name values using code

    You cannot do what you are trying to do. You will need to update your XML to something like the following:

    <my:Choices>
        <my:Choice name="Fruits">
            <my:Name>Apple</my:Name>
            <my:Name>Peach</my:Name>
            <my:Name>Pear</my:Name>
        </my:Choice>
        <my:Choice name="Veggies">
            <my:Name>Carrot</my:Name>
            <my:Name>Pea</my:Name>
        </my:Choice>
    </my:Choices>

    With this structure, you can now "filter" your choices in the second list based on the @name attribute of the my:Choice element. You can now also use the @name attribute to populate your first list.

    InfoPath just doesn't give you enough flexibility to dynamically change the XPath (i.e. /my:Fruits/my:Fruit vs. /my:Veggies/my:Veggie) on the fly.

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