Question:
How to pass VBScript variable value to JavaScript funcrion as parameter in ASP?
rAh!L
2007-10-21 00:54:48 UTC
Hello,
I am a naive programmer in ASP. Currently I am making a web using ASP (VBScript). I am having one problem here. My Coding language is VBScript. I have fetched data from database and stored values into VBScript arrays. I have a function in Jscript to create DHTML layer. Now I want to call this Jscript function with these fetched values on onmouseover & onmouseout events. But the problem is Internet Explorer does not recognize when I make a call to Jscript function.
Code that I have written is like this:


<%dim itemTitle(10)
dim itemDesc(10)
dim counter
counter=0
For counter=0 to 9
‘ Code to fetch data from database%>

View


<%Next%>
If I do not use arguments then it works fine and shows blank layer but it does not appear when I try to pass arguments to function.
Thanks
Four answers:
2007-10-21 03:28:51 UTC
1- you should notice that -unlike VBScript- javascript is case sensitive and all reserved words (e.g function) are in lower case, so you should write "function" not "Function":

function showData(title,desc) { // ...



2- itemTitle is a "server-side" variable, so it is undefined in client-side script. to pass the items to client-side, you should use response.Write or <%=%> construct:



<%dim itemTitle(10)

dim itemDesc(10)

dim counter

counter=0

For counter=0 to 9

‘Code to fetch data from database%>

", "<%=itemDesc(counter)%>")'>Text



<%Next%>



which will produce a HTML code like this:

...

.

.

.

Loading...