Solved

Mixing VBScript, JavaScript and HTML

Posted on 2004-09-03
5
394 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 50 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

738 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