Forum Moderators: open

Message Too Old, No Replies

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

         

tirengarfio

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

10+ Year Member



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

birdbrain

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



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