1 Reply Latest reply on Nov 9, 2010 11:19 PM by Steve L Walker

    Dropdown auto populate

    Gee68 Level 1

      I am designing

      a form with a combo box dropdown list of a

      ll the 51 states and I want the for if i se

      lect a state(il) it displays let say the tax rate of

      il in a textbox. But I want to do this for all the states


      it seems an if statement or xml will be my best bet

      and sample or tutorial somewhere

        • 1. Re: Dropdown auto populate
          Steve L Walker Level 5

          This is a two part problem, data binding and accessing data sources. The following addresses problem one, data binding. Build an XML instance to express the sales tax rates by state. I did a partial list of states and added 'TaxRates.xml' as the preview data source.


          <?xml version="1.0"?>




               <State id="" salesTax=""/>

               <State id="AK" salesTax="0.00"/>

               <State id="AL" salesTax="4.00"/>

               <State id="AR" salesTax="6.00"/>

               <State id="AZ" salesTax="5.60"/>

               <State id="CA" salesTax="8.25"/>





          Built an XML schema to describe the XML instance and add it as a data connection. My schema is embedded in the attached form. The schema 'TaxRates.xsd' is attached also.


          <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xfadata="http://www.xfa.org/schema/xfa-data/1.0/">

          <xsd:element name="form1">



              <xsd:element ref="subform1"/>




          <xsd:element name="subform1">



              <xsd:element ref="taxRates"/>




          <xsd:element name="taxRates">



             <xsd:element name="State" maxOccurs="51">


               <xsd:attribute name="id" type="xsd:string"/>

               <xsd:attribute name="salesTax" type="xsd:string"/>








          Use dynamic binding to bind the state drop-down list to the data connection. In the 'state' data binding specify the Item Text as the attribute 'id' and Item Value as the attribute 'salesTax'.




          In the exit event of 'state' add JavaScript to assign the raw value of 'state' to the raw value of 'taxRate'.


          // form1.page1.subform1.state::exit - (JavaScript, client)

          form1.page1.subform1.taxRate.rawValue = this.rawValue;