cotton_gear said:
Hi,
Depending on the user input I need to disbale/enable some of the links
in my page. When disbled I need to display the links as normal text
with cursor changed to mouse pointer style and when enabled I need to
change it back to the normal link.
I tried using document.getElementsById('myLink').style but I am getting
'Object doesnt support this property...'
Can you suggest please ?
<html>
<head>
<title>enable links</title>
<script type="text/javascript">
function returnTrue() { return true; }
function returnFalse() { return false }
function enableLink(linkid,enable) {
var link=document.getElementById(linkid);
if(enable) {
link.onclick=returnTrue;
link.style.textDecoration="underline";
link.style.cursor="pointer";
} else {
link.onclick=returnFalse;
link.style.textDecoration="none";
link.style.cursor="default";
}
}
</script>
</head>
<body>
<a id="alpha" href="http://www.google.com">google</a><br>
<a id="beta" href="http://www.wikipedia.com">wikipedia</a><br>
<a id="gamma" href="http://www.yahoo.com">yahoo</a><br>
<button onclick="enableLink('beta',false)">disable wiki</button><br>
<button onclick="enableLink('beta',true)">enable wiki</button><br>
</body>
</html>