Go Back   Velocity Reviews > Newsgroups > XML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

XML - Passing a javascript variable to an external xsl/xml file

 
Thread Tools Search this Thread
Old 07-07-2009, 05:00 PM   #1
Unhappy Passing a javascript variable to an external xsl/xml file


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.

I.e.

Code:
function selectRow(evt) { evt = (evt) ? evt : window.event; var newRow = (evt.target) ? evt.target : 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(selectedRow.id) % 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.target) ? evt.target : evt.srcElement; evtRow = evtRow.parentNode; evtRow.className = "highlited"; //highlite the row by changing its //class } }

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:

Code:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" (board didnt like my xsl link) <xsl:template match="/"> <html> <head> </head> <body> <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'"> <tr> <td> <xsl:value-of select="@id"/> </td> <td> <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> </td> </tr> </xsl:if> </xsl:for-each> </table> <input type="submit" id="btnSubmit" name="btnSubmit" value="Submit" /> </form> </body> </html> </xsl:template> </xsl:stylesheet>

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...

Regards,

Sykth.


sykth
sykth is offline   Reply With Quote
Old 10-11-2009, 01:18 PM   #2
MoBo
Junior Member
 
Join Date: Oct 2009
Posts: 1
Question 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" />


MoBo
MoBo is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing value with out using variable in query string in PHP! Ali_ggl General Help Related Topics 0 11-29-2008 12:22 PM
Address Bus and External Data Bus Confusion LoXodonte A+ Certification 1 04-18-2006 10:09 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46