Solved

Mixing VBScript, JavaScript and HTML

Posted on 2004-09-03
5
389 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
5 Comments
 
LVL 36

Expert Comment

by:Zyloch
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now