
October 9th, 2004, 04:56 AM
|
|
Registered User
|
|
Join Date: Sep 2004
Posts: 22
Time spent in forums: 8 m 28 sec
Reputation Power: 0
|
|
|
dropdown preceding-sibling unique id
I have a dropdown which I want it to be able to loop through the first generated-id's by category then i want it to check it's preceding-sibling to create another generated-id for brands. here is the code. The idea is to filter the first drop down which works fine then filter the second by category-and-brand. Any ideas or help would much be appreciated.
Code:
<products last-updated="01/10/04">
<product>
<id>MB-103</id>
<category>Motherboards</category>
<brand>Gigabyte</brand>
<units-instock>5</units-instock>
<sell-price>2.00</sell-price>
<cost-price>1.00</cost-price>
<thumb>images/test.gif</thumb>
<image>images/testing.gif</image>
<description>My Description</description>
</product>
<product>
<id>MB-104</id>
<category>Motherboards</category>
<brand>ASUS</brand>
<units-instock>5</units-instock>
<sell-price>2.00</sell-price>
<cost-price>1.00</cost-price>
<thumb>images/test.gif</thumb>
<image>images/testing.gif</image>
<description>My Description</description>
</product>
<product>
<id>MB-105</id>
<category>Hard Drives</category>
<brand>Seagate</brand>
<units-instock>5</units-instock>
<sell-price>2.00</sell-price>
<cost-price>1.00</cost-price>
<thumb>images/test.gif</thumb>
<image>images/testing.gif</image>
<description>My Description</description>
</product>
</products>
<xsl:key name="categories" match="product" use="category"/>
<xsl:key name="brands" match="product" use="brand" />
<xsl:template match="products">
<select id="category">
<xsl:for-each select="product[generate-id() = generate-id(key('categories', category)[1])]">
<option><xsl:value-of select="category" /></option>
</xsl:for-each>
</select>
<select id="brands">
<xsl:for-each select="product[generate-id() = generate-id(key('brands', brand)[1])]">
<xsl:if test="preceding-sibling::category[generate-id() = generate-id(category[(.)='Motherboards'][1])]">
<option><xsl:value-of select="following-sibling::brand" /></option>
</xsl:if>
</xsl:for-each>
</select>
</xsl:template>
|