Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Generate HTML form combo from XML list - clientside

Status
Not open for further replies.

hardcoder

Programmer
Feb 16, 2002
17
US
Here's the idea:
An XML (xsl?) file with a list like:
<combo1>
<option value=&quot;1&quot;>One</option>
<option value=&quot;2&quot;>Two</option>
<option value=&quot;3&quot;>Three</option>
</combo1>
<combo2>
<option value=&quot;A&quot;>Aye</option>
<option value=&quot;B&quot;>Bee</option>
<option value=&quot;C&quot;>See</option>
</combo2>

Now can I make an html (or xml?) file, that uses this XML listing to generate two combo boxes with the appropriate values and display strings?

Really need this. I could use VBSCript and the DOM if required - but I thot I'd ask first if there's a way to simply use XML/XSL and let the combo boxes generate themselves!

Thanks very much! Lyra Computing
 
Try using a template in your stylesheet matching &quot;combo1&quot; or &quot;combo2&quot; with a for-each loop to write out your list options:

(assumes you are using the following namespace for XSL: &quot; version=&quot;1.0&quot;)

---------------
<xsl:template match=&quot;combo1|combo2&quot;>
<select name=&quot;{name(.)}&quot;>
<xsl:for-each select=&quot;option&quot;>
<xsl:copy-of select=&quot;.&quot; />
</xsl:for-each>
</select>
</xsl:template>
---------------

This example uses the name of your element as the name for the drop-down list - which may or may not be what you want. The options are copied, including their values.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top