XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
rick kingSubject: filtering XML results dynamically with select dropdown
Author: rick king
Date: 27 Mar 2007 11:37 AM
I'd like to use a select dropdown to act as a filter when displaying my XML results. I'm assuming Javascript could set the filter criteria of my XSLT depending on the selection in the select menu.

So, a user would select a category from the select dropdown, and that selection would be passed to the <xsl:for-each> statement and filter by category. Something like the following:

<xsl:for-each select="catalog/coupons[category='@cateogry']">

I'm just not sure how to do this. Is there a javascript (or maybe a VB script) that can do this?

So far, I've got the select dropdown populated with the <category> node, and I've created a parameter for category. Now I'm stuck!

Here's my MXL:

<?xml version="1.0" ?>
<catalog>
<coupons>
<title>Title</title>
<category>Category</category>
<description>Decription</description>
<coupons>
<catalog>
<coupons>
<title>Title2</title>
<category>Category2</category>
<description>Decription2</description>
<coupons>

Here's my XSLT:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl:key name="itemType" match="catalog/coupons/category" use="."/

<xsl:param name="category"/>
<xsl:template match="/">

<script language="JavaScript">
<xsl:comment>
function setForm()
{
'hmmm...')
}
</xsl:comment>
</script>


<table width="550" cellpadding="6" >
<tr >
<td >

<!-- DropDown -->
<xsl:element name="select" >
<xsl:attribute name="name">category</xsl:attribute>
<xsl:attribute name="onchange_">setForm()</xsl:attribute>
<option name="selected">Choose Category </option>


<xsl:for-each select="catalog/coupons/category[count(. |
key('itemType', .)[1]) = 1]">
<OPTION>
<xsl:attribute name="class"></xsl:attribute>
<xsl:value-of select="."/>
</OPTION>
</xsl:for-each>
</xsl:element>
<!-- DropDown -->


</td>
</tr>
</table>
<table width="600" cellpadding="6" >


<tr valign="top" class="underline">
<td align="left" width="200" >Title</td>
<td align="left" width="200">Category </td>
<td align="left" width="200">Description</td>
</tr>


<xsl:for-each select="catalog/coupons[category='@cateogry']">
<tr valign="top" class="underline">
<td >
<xsl:value-of select="title"/>
</td>
<td>
<xsl:value-of select="category"/></td>
<td>
<xsl:value-of select="description"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

Any help would be much appreciated!
Thanks,
Rick



Postnext
Tony LavinioSubject: filtering XML results dynamically with select dropdown
Author: Tony Lavinio
Date: 27 Mar 2007 12:05 PM
A better place to ask this would be on a XSLT list, such xsl-list run
by Mulberry Technologies, or, since you're talking about VB, one of
the Microsoft newsgroups.

Postnext
rick kingSubject: filtering XML results dynamically with select dropdown
Author: rick king
Date: 27 Mar 2007 01:05 PM
thanks, I'll try those as well...

Posttop
rick kingSubject: filtering XML results dynamically with select dropdown
Author: rick king
Date: 27 Mar 2007 01:44 PM
thanks, I'll try those as well...

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.