[xsl] Difficulty with an msxsl:script function.

Subject: [xsl] Difficulty with an msxsl:script function.
From: Tomas Olsson <tomas.olsson@xxxxxxxxxxxxx>
Date: Tue, 19 Dec 2000 07:29:49 +0100
Hi!

I'm having problem with an msxsl:script function of mine.
The function looks like this:

<msxsl:script language="JavaScript" implements-prefix="user">
	function getLanguage()
	{
		var
lang=document.mycombo.example.options[document.mycombo.example.selectedIndex
].value
		return lang;
	}	
</msxsl:script>

I have created a combo box which contains different languages. When my 
function is called it should return the language which is currently
selected.

The function is called by the following line:
<xsl:variable name="Language" select="user:getLanguage()"/>

However, when my function is called I get an error message:
--------------------------------------------------------------------------
Microsoft JScript runtime error 'document' is undefined line = 5, col = 3 
(line is offset from the tag). Error returned from property or method call. 
--------------------------------------------------------------------------

If I "hard code" the variable returned in the function to e.g.
"var lang = "Swedish", the function executes without any problem. 

So my question is: Where can i place my function in order for "document"
to be defined before the function is called? Is this even possible? Or maybe
there is another way of doing this?

Grateful for any answers!

/Tomas Olsson


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread