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 January 6th, 2006, 04:22 PM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I create a jump menu in XSLT?

How do I create a jump menu in XSLT? Can I accomplish this without using scripting? Thanks.

KWilliams
 
Old January 6th, 2006, 06:44 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I don't know what a jump menu is.

If you can show the input XML you are starting with and an example of the HTML that you want to generate, then we can help you construct the XSLT to get from one to the other.



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 6th, 2006, 06:47 PM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I was able to accomplish this my doing the following:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    <html>
    <head>
        <script>
            <![CDATA[
            function MM_jumpMenu(targ,selObj,restore){ //v3.0
                eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
                    if (restore) selObj.selectedIndex=0;
            }
            ]]>
        </script>
    </head>
    <body>
    <xsl:variable name="currentpath">http://www.mysite.com.aspx?#38;record_id=</xsl:variable>
    <form name="searchform" action="$currentpath" method="post">
        <select name="bycategory" onChange="MM_jumpMenu('parent',this,0)">
            <option value="" selected="true">- Select a Category -</option>
            <option value="{$currentpath}cat1">Item 1</option>        <option value="{$currentpath}cat2">Item 2</option>
            <option value="{$currentpath}cat3">Item 3</option>
        </select>
    </form>
    </xsl:template>
</xsl:stylesheet>
Thanks anyway:)

KWilliams
 
Old January 6th, 2006, 08:10 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I'm not sure why you're using XSLT for this since it doesn't seem to be a transformation - what is the input? Why can't you just write a fixed HTML page?

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 9th, 2006, 10:34 AM
Banned
 
Join Date: Jul 2005
Posts: 317
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:I'm not sure why you're using XSLT for this since it doesn't seem to be a transformation - what is the input? Why can't you just write a fixed HTML page?
I'm using the XSLT page with an XML/XSLT on-the-server transformation using ASP.NET's transformNode method. And I'm trying to do almost all of my solutions without much additional scripting if at all possible. But my new solution has been working very well, and only required that I pass a parameter from XSLT to ASP.NET back and forth using the following method in ASP.NET:
Code:
Dim record_id_qs = Request.QueryString("record_id")
Dim record_id
If record_id_qs = "" Then
record_id = ""
Else
record_id = xsl.selectSingleNode("//xsl:param[@name='record_id']")
record_id.SetAttribute("select", "'" & record_id_qs & "'")
End If
...and by adding that bit of JavaScript to the top of the page. It works for me, and it seems to be very efficient. If you have other ideas of how I could have accomplished the same thing in another way, I'd love to hear about it, as I'm always learning. Thanks Michael.

KWilliams





Similar Threads
Thread Thread Starter Forum Replies Last Post
how create menubar, menu, menu item in xsl vijayanmsc XSLT 1 June 5th, 2006 06:43 AM
How do I create a menu in xslt? TrixiePix XSLT 0 December 8th, 2005 11:22 AM
hide jump menu? lian_a Classic ASP Basics 8 December 10th, 2004 08:33 AM





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