View Full Version : Getting output from Spry dropdown?

11-21-2007, 01:16 PM
Hi all,
I'm trying to search an XML document using drop down menus. I'm filtering using XSL, but I want to know how to use the output of a Spry dropdown menu to filter the rest of the XML. Here's some basic code:

<?xml version="1.0" encoding="utf-8" ?>
- <!-- DWXMLSource="company.xml"
<!DOCTYPE xsl:stylesheet (View Source for full doctype...)>
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
- <xsl:template match="/">
- <html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
- <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script src="SpryAssets/xpath.js" type="text/javascript" />
<script src="SpryAssets/SpryData.js" type="text/javascript" />
- <script type="text/javascript">
- <xsl:text disable-output-escaping="yes">
- <![CDATA[ var ds1 = new Spry.Data.XMLDataSet("company.xml", "company/department/employee/job",{distinctOnLoad:true});

- <body>
- <div spry:region="ds1">
- <select name="select" spry:repeatchildren="ds1">
<option value="{job}">{job}</option>
<p> </p>
- <table border="1">
- <tr>
- <xsl:for-each select="company/department/employee">
- <xsl:if test="job = 'Programmer'">
- <tr>
- <td>
<xsl:value-of select="name" />
- <td>
<xsl:value-of select="job" />
- <td>
<xsl:value-of select="salary" />

As you can see, i'm currently filtering using a xml:if function. The current filter will only give me the output of staff who are programmers (<xsl:if test="job = 'Programmer'">). What I want to do is use the output of the Spry drop down menu (ds1) to use as the filter, e.g. <xsl:if test="job = DS1">, but I don't know the correct way to do this.

If anyone could help it would be great. Hopefully it's pretty simple.