Solved

Mixing VBScript, JavaScript and HTML

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

Suggested Solutions

Title # Comments Views Activity
How to redirect all users but me properly to another page with htaccess 2 96
Where can I find... 1 34
hosting images 4 30
Two wordpress questions 3 46
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
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…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

803 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