admin管理员组文章数量:1320661
i have a hyperlink code like : Click Here and i want to customize this link on the basis of my radio button click,which are like : YES NO on radio-button value:'yes',i want to enable the hyperlink. while on radio-button value:'no',i want to disable the hyperlink. So,to make the hyperlink disable after clicking radio-button 'NO', i have written the following in disable-link() method : function disable-link() { //document.getElementById('disable-link').disabled=true; document.getElementById('disable-link').href = '#'; } Now,what i have to write in enable-link() method so that the hyperlink gets re-enabled after clicking radio-button 'YES'
function enable-link()
{
//document.getElementById('disable-link').disabled=false;
// SOME LINE OF CODE TO RE-ENABLE THE LINK
}
document.getElementById('disable-link').disabled=true*/*false; -: it makes the disable but user is able to click on the hyperlink though.So, i have used "document.getElementById('disable-link').href = '#';" -: it makes the link unclickable too Please suggest.
i have a hyperlink code like : Click Here and i want to customize this link on the basis of my radio button click,which are like : YES NO on radio-button value:'yes',i want to enable the hyperlink. while on radio-button value:'no',i want to disable the hyperlink. So,to make the hyperlink disable after clicking radio-button 'NO', i have written the following in disable-link() method : function disable-link() { //document.getElementById('disable-link').disabled=true; document.getElementById('disable-link').href = '#'; } Now,what i have to write in enable-link() method so that the hyperlink gets re-enabled after clicking radio-button 'YES'
function enable-link()
{
//document.getElementById('disable-link').disabled=false;
// SOME LINE OF CODE TO RE-ENABLE THE LINK
}
document.getElementById('disable-link').disabled=true*/*false; -: it makes the disable but user is able to click on the hyperlink though.So, i have used "document.getElementById('disable-link').href = '#';" -: it makes the link unclickable too Please suggest.
Share Improve this question asked Nov 1, 2012 at 9:28 puneet2289puneet2289 751 gold badge2 silver badges10 bronze badges 01 Answer
Reset to default 5<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>StackoverFlow answer for question</title>
<script type="text/javascript">
var link,color;
function disable_link() {
document.getElementById('testlink').disabled=true;
link = document.getElementById('testlink').href;
document.getElementById('testlink').removeAttribute('href');
//document.getElementById('testlink').style.color = "grey";
}
function enable_link() {
document.getElementById('testlink').setAttribute("href",link);
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p>
<label>
<input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_0" onchange="disable_link();" />
Radio</label>
<br />
<label>
<input type="radio" name="RadioGroup1" value="radio" id="RadioGroup1_1" onchange="enable_link();" />
Radio</label>
<br />
</p>
<a id="testlink" href="http://www.yahoo."> test </a>
</form>
</body>
</html>
本文标签: javascriptdisableenable a hyperlink by clicking on radiobuttonsStack Overflow
版权声明:本文标题:javascript - disable-enable a hyperlink by clicking on radio-buttons - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742063818a2418711.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论