473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Using javascript to capture the output of an anchor to alter a variable

I am programming an interactive CV using xml, xslt and java script. The

page consists of a header which contains links to various 'sections' on

the xml cv, a left and right menu, and a central panel. The central
panel is intended to display the main content of the cv: when an anchor

is selected from the header then the detail is supposed to appear. The
javascript is supposed to select the appropriate section 'onclick' and
output it. This is done in template 'teevee'. XSLT:

<?xml version="1.0" encoding="ISO8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:preserve-space elements="*" />
<xsl:template match="cv">
<html>
<head>
<title>
<xsl:text>CV: </xsl:text>
<xsl:value-of select="section[1]/personalName"/>
</title>
</head>
<body>
<table>
<tr>
<td width="100%" colspan="3">
<xsl:call-template name="top"/>
</td>
</tr>
<tr>
<td width="20%" class="borderbox" title="borderbox"
id="left">
<xsl:call-template name="address"/>
</td>
<td width="60%" class="main" title="main" id="centre">
<xsl:call-template name="teevee"/>
</td>
<td width="20%" class="borderbox" title="borderbox"
id="right">
<xsl:call-template name="portfolio"/>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template name="top">
<xsl:for-each select="section">
<span title="{name/@desc}" class="button">
<a name="controller" id="{@id}">
<xsl:value-of select="child::name"/>
</a>
</span>
<xsl:if test="not(position()=last())">
<xsl:text| </xsl:text>
</xsl:if>
</xsl:for-each>
<h1 title="{section[1]/personalName}"
class="{name(section[1]/personalName)}">
<xsl:value-of select="section[1]/personalName"/></h1>
<span title="{name(section[1]/objective)}"
class="{name(section[1]/objective)}"><xsl:value-of
select="section[1]/objective"/></span>
<hr/></xsl:template>
<xsl:template name="address">
<h2 title="{section[2]/name/@desc}"
class="{name(section[2]/name)}">
<xsl:value-of select="section[2]/name"/>
</h2>
<span title="{name(section[2]/name/@desc)}"
class="{name(section[2]/name)}">
<xsl:text>Address: </xsl:text>
<p title="{name(section[2]/address/houseName)}">
<xsl:value-of select="section[2]/address/houseName"/>
</p>
<p title="{name(section[2]/address/address)}">
<xsl:value-of select="section[2]/address/address"/>
</p>
<p title="{name(section[2]/address/town)}">
<xsl:value-of select="section[2]/address/town"/>
</p>
<p title="{name(section[2]/address/postcode)}">
<xsl:value-of select="section[2]/address/postcode"/>
</p>
</span>
<span title="{name(section/telephone)}"
class="{name(section/telephone)}">
<xsl:text>Telephone: </xsl:text>
<p title="{name(section[2]/telephone/land)}">
<xsl:value-of select="section[2]/telephone/land"/>
</p>
<p title="{name(section[2]/telephone/mobile)}">
<xsl:value-of select="section[2]/telephone/mobile"/>
</p>
<p title="{name(section[2]/telephone/work)}">
<xsl:value-of select="section[2]/telephone/work"/>
</p>
</span>
<span title="{name(section[2]/email)}"
class="{name(section[2]/email)}">
<xsl:text>Email: </xsl:text><p
title="{name(section[2]/email)}"
class="{name(section[2]/email)}"><xsl:value-of
select="section[2]/email"/></p>
</span>
</xsl:template>
<xsl:template name="portfolio"><h2
title="section[11]/name/@desc"
class="{name(section[11]/name)}">
<xsl:value-of select="section[11]/name"/>
</h2>
<xsl:for-each select="section[11]/period">
<span title="{name()}" class="{name()}">
<h3 title="{name(periodName)}">
<xsl:value-of select="periodName"/>
</h3>
<p title="{name(date)}" class="{name(date)}">
<xsl:value-of select="date/from"/- <xsl:value-of
select="date/to"/>
</p>
<p title="{name(groups)}" class="{name(groups)}">
<xsl:value-of select="groups"/>
</p>
<p title="{name(project)}" class="{name(project)}">
<xsl:value-of select="project"/>
</p>
</span>
</xsl:for-each>
</xsl:template>
<xsl:template name="teevee">
<xsl:param name="channel" select="3"/>
<xsl:value-of select="section[$channel]"/>
<script type="text/javascript">
document.getElementByName("controller").onClick=do cument.getElementByName("*channel").value=document .write("channel");

</script>
</xsl:template>
</xsl:stylesheet>
I am programming an interactive CV using xml, xslt and java script. The

page consists of a header which contains links to various 'sections' on

the xml cv, a left and right menu, and a central panel. The central
panel is intended to display the main content of the cv: when an anchor

is selected from the header then the detail is supposed to appear. The
javascript is supposed to select the appropriate section 'onclick' and
output it. This is done in template 'teevee'. XSLT:

<?xml version="1.0" encoding="ISO8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:preserve-space elements="*" />
<xsl:template match="cv">
<html>
<head>
<title>
<xsl:text>CV: </xsl:text>
<xsl:value-of select="section[1]/personalName"/>
</title>
</head>
<body>
<table>
<tr>
<td width="100%" colspan="3">
<xsl:call-template name="top"/>
</td>
</tr>
<tr>
<td width="20%" class="borderbox" title="borderbox"
id="left">
<xsl:call-template name="address"/>
</td>
<td width="60%" class="main" title="main" id="centre">
<xsl:call-template name="teevee"/>
</td>
<td width="20%" class="borderbox" title="borderbox"
id="right">
<xsl:call-template name="portfolio"/>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
<xsl:template name="top">
<xsl:for-each select="section">
<span title="{name/@desc}" class="button">
<a name="controller" id="{@id}">
<xsl:value-of select="child::name"/>
</a>
</span>
<xsl:if test="not(position()=last())">
<xsl:text| </xsl:text>
</xsl:if>
</xsl:for-each>
<h1 title="{section[1]/personalName}"
class="{name(section[1]/personalName)}">
<xsl:value-of select="section[1]/personalName"/></h1>
<span title="{name(section[1]/objective)}"
class="{name(section[1]/objective)}"><xsl:value-of
select="section[1]/objective"/></span>
<hr/></xsl:template>
<xsl:template name="address">
<h2 title="{section[2]/name/@desc}"
class="{name(section[2]/name)}">
<xsl:value-of select="section[2]/name"/>
</h2>
<span title="{name(section[2]/name/@desc)}"
class="{name(section[2]/name)}">
<xsl:text>Address: </xsl:text>
<p title="{name(section[2]/address/houseName)}">
<xsl:value-of select="section[2]/address/houseName"/>
</p>
<p title="{name(section[2]/address/address)}">
<xsl:value-of select="section[2]/address/address"/>
</p>
<p title="{name(section[2]/address/town)}">
<xsl:value-of select="section[2]/address/town"/>
</p>
<p title="{name(section[2]/address/postcode)}">
<xsl:value-of select="section[2]/address/postcode"/>
</p>
</span>
<span title="{name(section/telephone)}"
class="{name(section/telephone)}">
<xsl:text>Telephone: </xsl:text>
<p title="{name(section[2]/telephone/land)}">
<xsl:value-of select="section[2]/telephone/land"/>
</p>
<p title="{name(section[2]/telephone/mobile)}">
<xsl:value-of select="section[2]/telephone/mobile"/>
</p>
<p title="{name(section[2]/telephone/work)}">
<xsl:value-of select="section[2]/telephone/work"/>
</p>
</span>
<span title="{name(section[2]/email)}"
class="{name(section[2]/email)}">
<xsl:text>Email: </xsl:text><p
title="{name(section[2]/email)}"
class="{name(section[2]/email)}"><xsl:value-of
select="section[2]/email"/></p>
</span>
</xsl:template>
<xsl:template name="portfolio"><h2
title="section[11]/name/@desc"
class="{name(section[11]/name)}">
<xsl:value-of select="section[11]/name"/>
</h2>
<xsl:for-each select="section[11]/period">
<span title="{name()}" class="{name()}">
<h3 title="{name(periodName)}">
<xsl:value-of select="periodName"/>
</h3>
<p title="{name(date)}" class="{name(date)}">
<xsl:value-of select="date/from"/- <xsl:value-of
select="date/to"/>
</p>
<p title="{name(groups)}" class="{name(groups)}">
<xsl:value-of select="groups"/>
</p>
<p title="{name(project)}" class="{name(project)}">
<xsl:value-of select="project"/>
</p>
</span>
</xsl:for-each>
</xsl:template>
<xsl:template name="teevee">
<xsl:param name="channel" select="3"/>
<xsl:value-of select="section[$channel]"/>
<script type="text/javascript">
document.getElementByName("controller").onClick=do cument.getElementByName("*channel").value=document .write("channel");

</script
</xsl:template
</xsl:stylesheet>

Jul 6 '06 #1
3 2361

Use prototype.js to capture events...
More information here:
http://wiki.script.aculo.us/scriptac.../Event.observe

Jul 6 '06 #2
mertas said the following on 7/6/2006 3:28 PM:
Use prototype.js to capture events...
Don't. There are better, easier, more reliable ways to do it.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 6 '06 #3

Randy Webb wrote:
mertas said the following on 7/6/2006 3:28 PM:
Use prototype.js to capture events...

Don't. There are better, easier, more reliable ways to do it.
Ok... = )
Then try this one:
http://www.quirksmode.org/js/introevents.html

Jul 6 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
9
by: Jay Donnell | last post by:
I have a function that is a few thousand lines of code (I didn't write it) and I want to capture the output and save it as a variable. This is very easy to do in php. It would look something like...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
17
by: compassSoftware | last post by:
Hi, I have two horizontal frames, one on top of the other. The top frame is an image map of a street with property boundary's on it. The bottom frame is a table with each row of the table...
5
by: elsenraat_76 | last post by:
Hello! I was wondering if someone could help me out with a problem I'm having? I'm trying to input a javascript value into an anchor tag (from a function), but don't have an event to call the...
4
by: Peter Jaffe | last post by:
I've seen a few posts on this topic, but still haven't found a clean solution. Anyone have other suggestions or feel that one of the options I highlight below is the way to go? The Problem...
8
by: Jeff Higgins | last post by:
Hi, In the variable "anchor" I would like to, (I think), use the value of the variable "text" in the predicate of the select expression. Is this possible? Is there a better way of doing...
9
by: Hirru | last post by:
Hi................., i want to capture event from vb dll file in javascript,actually i can already access all the function of that dll from javascript but i don know how to capture event raised by...
13
by: Jim Langston | last post by:
I had asked this in comp.lang.c++ with out any answers that would actually work, so I'm hoping someone here may know a way. I am calling C library functions that want to output to stdout. I need...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.