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 December 26th, 2006, 06:18 PM
Registered User
 
Join Date: Dec 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to smi13y
Default xsl javascript problem

Any idea why this script doesn't work?
It should work like this: http://www.ekcsoft.com/coding/js_hideexample.php

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<html xsl:version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml">

<script><![CDATA[

var hide= true;
    function toggleRows(tableId, tag){

        tbl = document.getElementById(tableId);

        var len = tbl.rows.length;

        var vStyle = (hide)? "none":"";

        for(i=1 ; i < len; i++){
             tbl.rows[i].style.display = vStyle;
        }

        if(hide)
            tag.innerHTML = "<b>Click here to show rows</b>";
        else
            tag.innerHTML = "<b>Click here to hide rows</b>";
        hide= !hide;
    }
]]></script>

<body



Try hiding/showing table rows here:

    <p onClick='toggleRows("myTable", this)' style='cursor:pointer'><b>Click here to hide rows </b></p>

    <table id="myTable" style="width:200px; border: thin solid blue;">
            <tbody>
                <tr>
                    <td>
                        Test cell 1
                    </td>
                    <td>
                       Test cell 2
                    </td>
                </tr>
                <tr>
                        <td>
                            Test cell 3
                        </td>
                        <td>
                           Test cell 4
                        </td>
                </tr>
                <tr>
                        <td>
                            Test cell 5
                        </td>
                        <td>
                           Test cell 6
                        </td>
                </tr>
            </tbody>
        </table>
</body>
</html>
 
Old December 26th, 2006, 07:27 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Looks to me like a Javscript question rather than an XSLT question.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript in Xsl using-Xalan-Problem angeshwar XSLT 1 May 7th, 2008 12:36 AM
XSL maybe javascript. suri_1811 XSLT 1 November 3rd, 2006 12:20 PM
Javascript with XSL drdexter33 XSLT 2 January 19th, 2006 01:36 PM
Problem with JavaScript in XSL viachi XSLT 3 August 30th, 2004 09:12 AM
Tricky Javascript/XSL '&' problem...... robster Javascript How-To 1 January 23rd, 2004 02:11 PM





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