It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Hyperlink

Hyperlink

Postby chickenny on Fri Nov 26, 2010 4:32 pm

I have a problem in javascript:
I have to do 26 Hyperlink like
A B C... X Y Z
for example when I click on letter G must be an alert message "G". How can I do this?
Can u help me please?
chickenny
 
Posts: 1
Joined: Fri Nov 26, 2010 4:27 pm

Re: Hyperlink

Postby tommys on Sat Dec 04, 2010 8:33 pm

Here is my solution. I'm not experienced in JavaScript, maybe this code is wrong, but at least it works.
Code: Select all
window.onload = createLinks;
function createLinks() {
   var links = ["a","b","c","d","e","f"];
   for (var i = 0;i<links.length;i++) {
      document.write("<a href='#' id=\""+links[i]+"\">"+links[i]+"</a><br />");
      document.getElementById(links[i]).onclick = writeMsg;
   }
}
function writeMsg() {
   alert(this.id);
}
tommys
 
Posts: 13
Joined: Thu Dec 02, 2010 5:23 pm


Who is online

Users browsing this forum: No registered users and 6 guests