XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 17th, 2004, 12:18 PM
CrystalCoder CrystalCoder is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 153 CrystalCoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 h 26 m 47 sec
Reputation Power: 5
XSL + JavaScript

Hello,

I am looping through a list of column names and I want to place those column names inside of a anchor tag that simply displayed hello world. I have something like the following:

<script>
function printMsg(msg)
{
alert(msg);
}
</script>

Later in my xsl sheet I have
<A> <xsl:attribute name="href">#</xsl:attribute> <xsl:attribute name="onclick">printMsg(@name);</xsl:attribute>
</A>

The links are displaying just. I can also get the links to print a simple hello message. My question is how do you pass the column name to java script for printing in the alert box?

Thanks

Reply With Quote
  #2  
Old August 17th, 2004, 03:22 PM
NotGoddess's Avatar
NotGoddess NotGoddess is offline
Kung-fu Kitty
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 350 NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level)NotGoddess User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 6 h 9 m 2 sec
Reputation Power: 10
Send a message via AIM to NotGoddess
Try this xml:
PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<?xml-stylesheet type="text/xsl" href="myxsl.xsl"?>
<xmldata>
<link href="#a" message="Hello A" title="AAA"/>
<link href="#b" message="Hello B" title="BBB"/>
<link href="#c" message="Hello C" title="CCC"/>
<link href="#d" message="Hello D" title="DDD"/>
</xmldata>

with this xsl (filename 'myxsl.xsl')
PHP Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

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

<xsl:output method="html" />

<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >

<head><title>navtest</title></head>
<script type="text/javascript">
<![CDATA[function printMsg(msg) { alert(msg); } ]]>
</script>
<body>
<xsl:for-each select="//link">
<A>
<xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute>
<xsl:attribute name="onclick">printMsg('<xsl:value-of select="@message"/>');</xsl:attribute>
<xsl:value-of select="@title"/>
</A>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSL + JavaScript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT