Solved

Mixing VBScript, JavaScript and HTML

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
The viewer will learn how to count occurrences of each item in an array.

830 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