Passing a javascript variable to an external xsl/xml file

Jul 7, 2009
Reaction score
Hi there,

I'm having a big problem trying to pass a "selected" variable from a html table to a xsl file for filtering off records.

My html table is constructed using javacript to import a xml file, and then styled using javascript to detect mouse click and hover events and thus assign classes to each table row.


function selectRow(evt) {
evt = (evt) ? evt : window.event;
var newRow = ( ? : evt.srcElement;
newRow = newRow.parentNode;

//reset event handlers for row being unselected
selectedRow.onmousedown = selectRow;
selectedRow.onmouseout = unhighliteRow;
selectedRow.onmouseover = highliteRow;

//erase event handlers for selected row
newRow.onmousedown = '';
newRow.onmouseout = '';
newRow.onmouseover = '';

//reset the row's color
if (parseInt( % 2 == 0) {
selectedRow.className = 'even';
} else {
selectedRow.className = 'odd';

newRow.className = "selected"; //select the row by changing its class
selectedRow = newRow;

function highliteRow(evt) {
evt = (evt) ? evt : window.event;
var evtRow = ( ? : evt.srcElement;
evtRow = evtRow.parentNode;

evtRow.className = "highlited"; //highlite the row by changing its



These functions are an example of how the table is styled. I would like to (upon clicking on a button entitled "edit applicant") to load my applicants.xml which is styled by my applicants.xsl:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" (board didnt like my xsl link)
 <xsl:template match="/">
 <form method="post" action="EditApplicant.asp">
 <h1>Edit Contact:</h1>
 <table border="1" cellpadding="2">
 <xsl:for-each select="applicants/applicant/*">
<xsl:if test="newRow.className ='selected'">
  <xsl:value-of select="@id"/>
<input type="text"> <xsl:attribute name="id"> <xsl:value-of select="@id" /> </xsl:attribute> <xsl:attribute name="name"><xsl:value-of select="@id" /></xsl:attribute> <xsl:attribute name="value"> <xsl:value-of select="text()" /> </xsl:attribute></input>
 <input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" />

However I can't seem to figure out how to pass the javascript variable from the current html/javscript file to my applicants.xsl/xml document so I can use it in my <xsl if> statement.

As you can probably tell by now - i'm aiming to select a table row with my mouse and then click my edit applicant link, which will then in turn only load up a table of the selected record for me to edit.

I appreciate this is quite a long post so I thank you for reading it - any advice you can give me would be most welcome, as being a bit new to all this, I'm going bonkers...




Oct 11, 2009
Reaction score
passing javaxcript variable to xsl variable - how to

I am also trying to do this...I have xsl code in which I call javascript to calculate the difference between a due date and the current date then based on the number of days left I set a status flag that I want to feed back to a column/field value in xsl so that I can sort on that column.
Since the [TODAY] variable in SharePoint is NOT dynamic, I had to use javascript to determine how many days were left between my due date and the current date. I have gotten my days left calculation to work thanks to a blog from Chistopher Johnson, but now I need to feed the Status Flag variable backt o xsl so that I can sort on it.

I am going crazy looking at all the blogs out there and please do not tell me to use a calculated column in SP with TODAY as TODAY is in SP is STATIC and I need to use a dynamic Current Date in my calculations.

In short I just need a simple way to feed the value of my javascript variable FlagStatus back to the value of the XSL field Status_x0020_Flag.

I think I need to do something with this code to reference the javascript variable for the value, but can't figure ut what to do.

Can anyone help?

<xsl:value-of disable-output-escaping="yes" select="@Flag_x0020_Status" />

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question