The fundamental problem to the approach you are trying is that the XSL processing instruction...

<?xml:stylesheet type="text/xsl" href="test.xsl"?>

...is done once, immediately upon loading the document resulting in an HTML object. This result is then like any static HTML file that then goes through Javascript event handling. The OnClick event handling is done much later when the user starts interacting with the transformed document. By this time the XSL processing is long over. XSL template handling is a set of operations that fire when the document is read. There is no opportunity to influence the processing with user input.

If you want your javascript to perform XSL functionality that varies based on user input, then you have to run your transforms using MSXML and set up runtime parameters using MSXML method calls.

The way you've done it, the value of your variable $item_no is set inside your XSL file and is read only. To have the XSL processing use a run-time varaible set by user input, you have to use a 'top-level' param (i.e. not iside a template) in the XSL. These can be modified via the XSLT api with an addParameter instruction To illustrate, the following XML produces an HTML page with javascript links that each choose a different section of the XML file based on which hyperlink is clicked:

When you load test.xml into IE, test.xsl will produce a menu of links, one for each inventory item. Note how the onclick attribute of each link is computed on this first pass using xsl:attribute. You could have just as easily produced a form with a dropdown list or somthing like that.

The callDetail javascript function takes the parameter and calls another stylesheet (detail.xsl) to output the requested detail. Note how the xslProc.addParameter passes the function parameter to the detail.xsl stylesheet. The result of the transformation is then written to the browser.

The Problem
How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side? I give a bit more background at the end.
The situation expressed as relational data
Let’s work through this. I’ve …

The Confluence of Individual Knowledge and the Collective Intelligence
At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language. A few years ago, …

This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…