Expand my Community achievements bar.

SOLVED

Dropdown auto populate

Avatar

Former Community Member

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 Accepted Solution

Avatar

Correct answer by
Former Community Member

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"?>

<form1>

  <subform1> 

   <taxRates>

     <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"/>

    </taxRates>

  </subform1>

</form1>

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:complexType>

   <xsd:sequence>

    <xsd:element ref="subform1"/>

   </xsd:sequence>

  </xsd:complexType>

</xsd:element>


<xsd:element name="subform1">

  <xsd:complexType>

   <xsd:sequence>

    <xsd:element ref="taxRates"/>

   </xsd:sequence>

  </xsd:complexType>

</xsd:element>


<xsd:element name="taxRates">

<xsd:complexType>

  <xsd:sequence>

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

    <xsd:complexType>

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

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

    </xsd:complexType>

   </xsd:element>        

  </xsd:sequence>

</xsd:complexType>

</xsd:element>


</xsd:schema>

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'.

Untitled.png

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;

Steve

View solution in original post

1 Reply

Avatar

Correct answer by
Former Community Member

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"?>

<form1>

  <subform1> 

   <taxRates>

     <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"/>

    </taxRates>

  </subform1>

</form1>

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:complexType>

   <xsd:sequence>

    <xsd:element ref="subform1"/>

   </xsd:sequence>

  </xsd:complexType>

</xsd:element>


<xsd:element name="subform1">

  <xsd:complexType>

   <xsd:sequence>

    <xsd:element ref="taxRates"/>

   </xsd:sequence>

  </xsd:complexType>

</xsd:element>


<xsd:element name="taxRates">

<xsd:complexType>

  <xsd:sequence>

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

    <xsd:complexType>

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

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

    </xsd:complexType>

   </xsd:element>        

  </xsd:sequence>

</xsd:complexType>

</xsd:element>


</xsd:schema>

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'.

Untitled.png

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;

Steve

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----