Hey guys,
I'm in desperate need for help! Isn't everyone that post though :)
Ok. I'm really new to XSLT so I'm guessing the problem I'm having is easily overcome... I hope cos I need to get this thing finished in about 5 hours. Everything is working on my webpage except for one thing... I need to add a button in the XSLT. The code supplied works fine except for the button section. It displays all the products, descriptions,etc... What I need as well, is to have a button for each product that has the following code attached to it
Context.Items("ProductID") = @name
(the name of the current product name)
Server.Transfer("AddToCart.aspx")
So it calls the addtocart page and the code in that adds the product to the shopping cart.
Ok, in the code below, I've tried heaps of things to get this working but I just can't figure it out.
Guys, any help here ASAP would be greatly appreciated! I'm a the business end of the rope at the moment so I'm really struggling. :(
Look forward to a solution.
oMavericko
Code:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version= "1.0">
<xsl:template match="/">
<xsl:for-each select="/productlist/product">
<TABLE width="75%" align="center" border="1">
<tr>
<td>Name: </td>
<td><xsl:apply-templates select="name"/></td>
<td RowSpan = "4" width= "0"> <xsl:apply-templates select="image"/></td>
</tr>
<tr>
<td>Code: </td>
<td><xsl:apply-templates select="code"/>t</td>
</tr>
<tr>
<td>Category: </td>
<td><xsl:apply-templates select="category"/></td>
</tr>
<tr>
<td>Price: </td>
<td><xsl:apply-templates select="price"/></td>
</tr>
<tr>
<td>Description: </td>
<td><xsl:apply-templates select="description"/></td>
<td>
<input type="button" onclick="Context.Items("ProductID") = prodid;Server.Transfer("AddToCart.aspx")" value="Add To Cart"/>
</td>
</tr>
</TABLE>
<p/>
</xsl:for-each>
</xsl:template>
<xsl:template match="name">
<b><xsl:value-of select="."/> </b>
</xsl:template>
<xsl:template match="code">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="price">
$<xsl:value-of select="."/>.00
</xsl:template>
<xsl:template match="category">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="description">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="image">
<img>
<xsl:attribute name="src">
<xsl:value-of select="." />
</xsl:attribute>
</img>
</xsl:template>
</xsl:stylesheet>