Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Passing a javascript variable to an external xsl/xml file

Thread Tools

Passing a javascript variable to an external xsl/xml file

sykth sykth is offline
Junior Member
Join Date: Jul 2009
Posts: 1
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...


Reply With Quote
MoBo MoBo is offline
Junior Member
Join Date: Oct 2009
Posts: 1
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" />
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing a variable value from Javascript to server variable shil ASP .Net 2 01-02-2007 09:33 PM
passing data from javascript variable to asp variable. Steve Cosh ASP General 1 11-18-2005 04:15 AM
Passing an external variable via .net into an XSL stylesheet Glenn Mantle ASP .Net 0 07-28-2004 04:24 PM
passing javascript variable into asp variable using vbscript Jonas Daunoravicius Javascript 5 07-17-2003 04:54 AM
passing javascript variable into asp variable using vbscript Jonas Daunoravicius ASP General 5 07-17-2003 04:54 AM