Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing "value-of select" values withing HTML tags on XSL page

Status
Not open for further replies.

notrut

Programmer
Feb 6, 2002
87
CA
Hi, I'm pretty new to XML and XSL and I was wondering if it is possible to use value-of select values within HTML tags. (I.E. I want to pass a the same value-of select value to a JavaScript Function and use that same value-of select value as an <A HREF ...>).


Here's the code that I have:

</xsl:template>
<xsl:template match=&quot;//Stop&quot;>
<tr>
<td class = &quot;gDescription&quot;>
<A HREF=&quot;JavaScript:popluateStop(<xsl:value-of select=&quot;@No&quot;/> )&quot;>
<xsl:value-of select=&quot;@No&quot;/></A> - <xsl:value-of select=&quot;@Name&quot;/>
</td>
</tr>
<xsl:apply-templates/>
</xsl:template>


However, this does not work because I have two < <. I've tried using the &quot;& lt;&quot; and the &quot;& gt; &quot;but then it just writes the <A HREF etc to the screen.

Is there anyway around this????

Any help would be greatly appreciated!!!
 
you need to build the HTML anchor element using xsl:element and xsl:attribute

-pete
 
Hi Palbano,

I tried doing this and the page loads properly, however, when I click on the link, I get an error:

</xsl:template>
<xsl:template match=&quot;//Stop&quot;>
<tr>
<td class = &quot;gDescription&quot;>
<xsl:element name=&quot;Stop&quot;>
<xsl:attribute name=&quot;StopNum&quot;><xsl:value-of select=&quot;@No&quot;/></xsl:attribute>
<A HREF=&quot;JavaScript:popluateStop(#StopNum)&quot;><xsl:value-of select=&quot;@No&quot;/></A> - <xsl:value-of select=&quot;@Name&quot;/>
</xsl:element>
</td>
</tr>
<xsl:apply-templates/>
</xsl:template>

I still am not able to get the #StopNum in the JavaScript function. Is this the correct way of using the xsl:element and attribute's????
 
Code:
<xsl:template match=&quot;Stop&quot;>
	<xsl:element name=&quot;a&quot;>
		<xsl:attribute name=&quot;href&quot;>
			Javascript:PopulateStop(<xsl:value-of select=&quot;@No&quot;/>);
		</xsl:attribute>
		<xsl:value-of select=&quot;@No&quot;/>
	</xsl:element>
</xsl:template>

-pete
 
Question: What about the {} shorthand? I have used this method in the past and just wondered if there was any reason not to use it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top