Hi All,
I am having a problem changing HREF and Text of a link from javascript. My code is as colos
<a href="javascript:Action(9,'remove');" id="thelink">Remove</a>
And the javascript code is:
Code:
function Action(locid,reqact){
var fltitle;
var flllink;
var flmsg;
if(reqact=="remove"){
atitle="Add";
newlink="Action(" + locid + ",'add')";
}
else if(reqact=="cancel"){//cancel sent
atitle="Add";
newlink="Action(" + locid + ",'add')";
}
else if(reqact=="add"){//add sent
atitle="Add";
newlink="Action(" + locid + ",'cancel')";
}
var al=document.getElementById("thelink");
al.innerHTML=atitle;
al.href="javascript:"+newlink;
//al.setAttribute('href',newlink);
}//end function
At first page load, it works fine. But then the link text nor its href don't change.
What could be the error please?