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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filter XML results with select menu

Status
Not open for further replies.

Diggum1

Programmer
Oct 14, 2004
67
US
I have an XML file where each coupon has a category node. For example:
<master>
<coupon>
<category>category 1</category>
<description>blah blah blah</description>
</coupon>

<coupon>
<category>category 2</category>
<description>blah blah blah</description>
</coupon>
</master>

I'd like to filter the results so that only results from a given category display. This would be in my XSL (just shows an example)

select name="filter">
<option>category 1</option>
<option>category 2</option>

<xsl:for-each select="master/coupon">
<xsl:value-of select="category"/>
<xsl:value-of select="description"/>
</xsl:for-each>


I'm not sure where to start. Is there a Javascript method to do this? How do I associate the select dropdown to the XSL?

Thanks
Rick
 
>I'd like to filter the results so that only results. from a given category display
><xsl:for-each select="master/coupon">
[tt]<xsl:for-each select="master/coupon[category='category 1']">[/tt]
The rest, I don't understand what you're asking without seeing what you're doing.
 
Thanks for the response.

So how would I make that filter criteria [category='category 1'] dependent on the dropdown menu?

For example, a user selects Category 1 from the dropwdown, it should dynamically update the filter criteria in the <xsl:for-each select="master/coupon[category='category 1']"> statement and only show those results.

So, maybe [category='category 1'] could be a variable, and that variable is updated by the dropdown? I'm just not sure...

Thanks



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top