Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2004, 07:20 AM
Registered User
 
Join Date: Apr 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Help for a beginner

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>






Similar Threads
Thread Thread Starter Forum Replies Last Post
xslt beginner question cfflexguy XSLT 4 October 16th, 2007 09:11 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
XSLT Beginner Issues faberd XSLT 2 March 21st, 2006 02:22 PM
beginner xslt processor question randallxski XSLT 3 March 24th, 2005 09:41 AM
Beginner Tilak_1 C# 2 January 21st, 2005 11:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.