?
Solved

Mixing VBScript, JavaScript and HTML

Posted on 2004-09-03
5
Medium Priority
?
398 Views
Last Modified: 2013-12-16
Below is a snippet of my code. Basically, I want to display a person's name when I mouse over their email address. I've tried using a Javascript function to do this, but I can't. Something tells me that I can't do it this way, but I thought I would bounce it off someone:


<script language="javascript1.1">
function change(html){
  PersonsName.innerHTML=html
}
</script>


<%

MyMouseOVer = onmouseover="javascript:change('Mike Tyson')" MyMouseOut = MyMouseout="javascript:change('')"

<TABLE>
<TR>
   Response.Write "<TD> <a" & MyMouseOver & MyMouseOut & "href=mailto:" & rtrim(ltrim(objRS("EmailAddress"))) &  ">" & rtrim(ltrim(objRS("EmailAddress"))) & "</a>"
   Response.Write "</font>"
   Response.Write "</TD>"

</TR>
</TABLE>

<div id="PersonsName"></div>

%>
0
Comment
Question by:ONYX
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11978236
Hi

Er... why don't you do this:

<%

Dim MyMouseOver
Dim MyMouseOut
MyMouseOver = "onmouseover=\"javascript:change('Mike Tyson')\""
MyMouseOut = "onmouseout=\"javascript:change('')\""

%>
<TABLE>
<TR>
<%
   Response.Write("<TD> <a href=mailto:" & rtrim(ltrim(objRS("EmailAddress"))) & MyMouseOver & " " & MyMouseOut & ">" & rtrim(ltrim(objRS("EmailAddress"))) & "</a>")
   Response.Write("</TD>")
%>
</TR>
</TABLE>
<div id="PersonsName"></div>



Regards,
Zyloch
0
 
LVL 3

Expert Comment

by:swarnajyothirmayi123
ID: 11980567
Hi,

Since you said you were using mailid, you can do this.

<a href='mailto:abc@abc.com' title='ABC ABC'>abc@abc.com</a>


Swarna
0
 

Author Comment

by:ONYX
ID: 11981056
Thanks for the responses. Zyloch, I'm not sure what you have is much different than what I have. If I'm missing something, please correct me. In any case, I tried it and same result. I think the problem is that the Javascript is looking for the div with the id=PersonsName, and it cannot find it. Thanks again.
0
 
LVL 36

Accepted Solution

by:
Zyloch earned 150 total points
ID: 11981299
You might want to try adding this function:

function getObj(id) {
   if (document.getElementById) {
      return(document.getElementById(id));
   } else if (document.all) {
      return(document.all[id]);
   } else if (document.layers) {
      return(document.layers[id]);
   } else {
      return false;
}


Then, change your function:

function change(html){
   if (myObj=getObj("PersonsName")) {
     myObj.innerHTM=html.toString();
   }
}
0
 
LVL 6

Expert Comment

by:Fahdmurtaza
ID: 11987455
I think Zyloch is right. I am not a jscript wizard but genaerally what I can sujjest is that you have to use the javascript separately and then just write the asp code that actually generaltes the html which will be calling the onmouseover script that will be a function shwing the name. But before that you have to call another javascript function that actually assigns a variable, the name contained in some hidden variable and then being displayed by the second function. I think getting your work this way will solve the problem.

Regards,
Fahd Murtaza
0

Featured Post

Stack Overflow Podcast - Developer Story

Welcome to the Stack Overflow podcast recorded Thursday July 20 at Stack Overflow Headquearters in NYC. Your hosts today are podcast regulars Jay Hanlon, David Fullerton, and Ilana Yitzhaki, plus the quite irregular Matt Sherman (Stack Overflow Engineering Manager extraordinaire)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question