Welcome to WebmasterWorld Guest from 54.224.11.137

Forum Moderators: open

Message Too Old, No Replies

A link that after clicking on it a function be executed and the text

     
11:35 am on Sep 29, 2009 (gmt 0)

New User

5+ Year Member

joined:Nov 30, 2008
posts:33
votes: 0


Hi,

i want to create a link that after clicking on it a function be executed and the text of the link be also changed, for example from "Click here to add this option" to "You have just added the option".

Any idea?

Ciao

Javi

2:32 pm on Sept 29, 2009 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member 10+ Year Member

joined:Oct 2, 2003
posts: 1005
votes: 34


Hi there tirengarfio,

does this help in some small way...


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">

<title></title>

<style type="text/css">
#mylink {
color:#000;
}
</style>

<script type="text/javascript">

function init(){
document.getElementById('mylink').onclick=function(){
this.firstChild.nodeValue='You have just added the option';
doStuff();
return false;
}
}

function doStuff(){
alert('...and the function has been activated');
}

if(window.addEventListener){
window.addEventListener('load',init,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',init);
}
}
</script>

</head>
<body>

<div>
<a id="mylink" href="#">Click here to add this option</a>
</div>

</body>
</html>


birdbrain