# Change XML Path? JavaScript?

**URL:** <https://forum.kirupa.com/t/change-xml-path-javascript/192456>\
**Category:** programming\
**Created:** [June 28, 2006, 6:38pm UTC](https://forum.kirupa.com/t/change-xml-path-javascript/192456 "2006-06-28T18:38:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevin1886](https://avatars.discourse-cdn.com/v4/letter/k/ce7236/32.png) [@kevin1886](https://forum.kirupa.com/u/kevin1886)\
**Post date:** [June 28, 2006, 6:38pm UTC](https://forum.kirupa.com/t/change-xml-path-javascript/192456/1 "2006-06-28T18:38:06Z")

</div>

Can some please help me?

(file type = .xsl)

I need some kind of javascript (or something that will work with this) that can switch from “//pic[@category]” to either:"//pic[@category=‘kitchen’]", “//pic[@category=‘bath’]”, “//pic[@category=‘home’]”. That is either done from a basic text link or a select form (I’ve tried both). This script will replace the following line (towards middle bottom of the .xsl):  
\<xsl:for-each select="**//pic[@category]**"\>

* * *

I tried doing a variation of a javascript:

\<script language=“JavaScript”\>  
function movepic(img\_name,img\_src) {  
document[img\_name].src=img\_src;  
}  
\</script\>

That uses:  
\<a href="#" onClick=“movepic(‘pix1’,‘image.jpg’)”\>LINK\</a\>

* * *

But it doesn’t work because \<xsl:for-each select="//pic[@category]"\> cannot have a name.  
(I didn’t put the variation js because it didn’t work.)

Any ideas?

Here’s my .xsl:

* * *

\<?xml version=“1.0” encoding=“ISO-8859-1”?\>\<xsl:stylesheet version=“1.0”  
xmlns:xsl=“[http://www.w3.org/1999/XSL/Transform](http://www.w3.org/1999/XSL/Transform)”\>\<xsl:template match="/"\>  
\<html\>  
\<body\>  
\<a name=“top”\>\</a\>  
\<div\>  
All Thumbnails:\<br /\>  
\<xsl:for-each select="//pic[@category]"\>  
\<xsl:variable name=“thumbs” select=“thumbnail”/\>  
\<xsl:variable name=“links” select=“link”/\>  
\<xsl:variable name=“titlename” select=“description”/\>  
\<a href="#{$links}"\>\<img src="{$thumbs}" class=“thumbss” title="{$titlename}"/\>\</a\>  
\</xsl:for-each\>  
\</div\>  
\<center\>  
\<div id=“greyba”\>  
\<table border=“0” cellspacing=“0” class=“maincontent”\>  
\<xsl:for-each select="//pic[@category]"\>  
\<tr\>  
\<td\>  
\<xsl:variable name=“anchors” select=“link”/\>  
\<a name="{$anchors}"\>\</a\>  
\<xsl:variable name=“srcl” select=“leftpic”/\>\<xsl:variable name=“srcr” select=“rightpic”/\>  
\<img src="{$srcr}" /\>\</td\>  
\<td class=“right” \>\<img src="{$srcl}" /\>\<br /\>  
\<xsl:value-of select=“description”/\>  
\</td\>\</tr\>  
\<tr\>  
\<td class=“botle”\>[\<a href="#top"\>back to top\</a\>]\</td\>  
\<td\>\</td\>  
\</tr\>  
\</xsl:for-each\>  
\</table\>  
\</div\>  
\</center\>  
\</body\>  
\</html\>  
\</xsl:template\>\</xsl:stylesheet\>

* * *

I hope you can help

**Thank you,  
Kevin**
