Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Message Too Old, No Replies

Passing vbscript variables to a javascript function

vbs to js

6:54 pm on Dec 4, 2003 (gmt 0)

10+ Year Member

I want to have a small popup message whenever a user mouseovers a row in my asp generated table. I have thought about dynamically generating divs and then making them visible/invisible on mouseover and mouseout but womdered how I could do this

do I, in the mouseover event just do this?

onMouseOver="Div_id.visible" onMouseOver="Div_id.invisible" or is this to simple to work!
I admit to asking afor I look or try anything out but hey, I can offer thanks!

2:43 pm on Dec 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

i'm not really sure where the subject of your post "Passing vbscript variables to a javascript function" is coming in to play...


3:42 pm on Dec 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

You don't need VBscript to do that, you can do that entirely with Javascript.

I'll sticky you the code, I didn't write most of it and I don't want to post the credits here because of the TOS

6:56 pm on Dec 6, 2003 (gmt 0)

10+ Year Member

How I was referring to the vbscript to javascript was that I have a javascript function that operates client side and posts a static text message on mouseover and removes it on mouseout. Now I am building an address search function which dynamically creates rows with which I attach the code to; each new row contains its address data. I got to wondering if I could just pass this information, dynamically, to the javascript function so that it displays row specific information on a mouseover. I am a GIS developer new to javascript and ASP. I guess that I can create a div which contains the info but thought the javascript function would be more 'clean'.

Any ideas?

4:57 am on Dec 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

you can insert any vbscript data into javascript code.


vbvariable = request.querystring("testvariable")

<script language = "javascript">
function showVBcode() {
var test1 = "some string here";

newvariable = test1 + <%=vbvariable%>;


*code has not been tested*


8:37 pm on Dec 7, 2003 (gmt 0)

10+ Year Member

I think I am not explaining myself properly; I am displaying a dynamic page which has a variable that updates each row dynaically. Lets say I get some data from an address database. Now I build an html table to store the data and each time a new row is added, I attach the address data for that row in that variable. How can I then, given the data is attached to a particular row and the name has not changed, just the variable, use the data. I was thinking of passing the data over on a passover like so

onMouseover="Javascript:ShowData('strAddressData')" onMouseOut="JavaScript:ShowData('')"

Where strAddressData is data built for each row. Now each time I add a row, this data is unique for this row i.e.

for rara
<TR onMouseover="Javascript:ShowData('strAddressData')" onMouseOut="JavaScript:ShowData('')">
Next rara

If you want I can post the actual code. As I said earlier; I have built the code to display static data. It works exellently. I don't know how to do this dynamically with ASP and database data. As a workaround, I have a showmodalwindow on the onClick event to open up a window showing the data, I just wanted to get a bit funvky and I think I will have to do it with Divs.

Unless you know different?!?! I am at a loss to work out how using my javascript function!


8:40 pm on Dec 7, 2003 (gmt 0)

10+ Year Member


<script language = "javascript">
function showVBcode(somevar)

<TR onMouseOver=showVBCode(<%= vbVariable %>)>

12:44 pm on Dec 8, 2003 (gmt 0)

10+ Year Member

Managed it:
strData = "34 Nutfield Road, Merstham. Surrey. RH1 3EW."
strTester = "ADHEAD" & CStr(i) 'i is the Loop variable


<div id=<%= strtestertwo %> class=header style="position:absolute; top:300; left:400; visibility:hidden; z-index:1;">
<%= strData %>

<tr bgcolor="<%= strBackColour %>" onMouseover="showHideLayers('<%= strtestertwo %>','','show');this.style.cursor='hand';" onMouseOut="showHideLayers('<%= strtestertwo %>','','hide')">

<script type="text/javascript" language="JavaScript">
function OpeningRun(){
window.status = "Your address search results..."

function makevisible(cur,which){
strength=(which==0)? 1 : 0.2

if (cur.style.MozOpacity)
else if (cur.filters)

function findObj(n, d) {
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;

function showHideLayers() {
var i,p,v,obj,args=showHideLayers.arguments;
for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
obj.visibility=v; }