homepage Welcome to WebmasterWorld Guest from 54.167.173.250
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Passing vbscript variables to a javascript function
vbs to js
phallett




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

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!

 

mattglet




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

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

-Matt

too much information




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

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

phallett




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

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?

mattglet




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

you can insert any vbscript data into javascript code.

i.e.

<%
vbvariable = request.querystring("testvariable")
%>

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

newvariable = test1 + <%=vbvariable%>;

alert(newvariable);
}
</script>

*code has not been tested*

-Matt

phallett




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

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('')">
<TD>
Add1
</TD>
<TD>
add2
</TD>
<TD>
town
</TD>
<TD>
state
</TD>
<TD>
postcode
</TD>
</TR>
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!

P

phallett




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

HOW CAN I DO THIS?!?!

<script language = "javascript">
function showVBcode(somevar)
{
alert(somevar);
}

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

phallett




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

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 %>
</div>

<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)
cur.style.MozOpacity=strength
else if (cur.filters)
cur.filters.alpha.opacity=strength*100
}

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; }
}
//-->
</SCRIPT>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved