View Full Version : Passing xml element data to a javascript/asp variable
TheLymner
08-19-2007, 03:47 PM
I have, what I believe, is a rather simple question. However, I cannot find the answer anywhere on the web nor in any of the library of xml or javascript/asp books available. How do I pass and store an xml element data (an interger) into a javascript/asp variable? I am not going to display the data (that I can do easily), rather the data is going to used to deteremine how the rest of the parent data is going to be displayed in any of 90 different places on the screen. It will determine not only the where but the size and the order of the display.
Respectfully
TheLymner
TheLymner
08-20-2007, 02:20 PM
"That was easy" I found a simple solution shortly after posting the request.
<xsl:template name="TEST" match="rack"> [place in head]
<script type="text/JavaScript">
var units='<xsl:value-of select="./slots"/>' [Stores the value of the element
/slots/ into js variable "units"]
var pxs=units * 30 [times the value of units by 30 and store it in variable "pxs"]
var nameNode='<xsl:value-of select="./hostName"/>' [Store the value of /hostName/ into js variable "nodeName"]
document.write ('<div class="host" style="position:absolute; z-index:42; top:0px; left:0px; width:200px; height:'+pxs+'px">'+nameNode+'</div>')
[Write the div and the variables]
</script>
TheLymner
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.