Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Hyperlink if Checkbox is Checked 2

Status
Not open for further replies.

jmeckley

Programmer
Jul 15, 2002
5,269
US
I can't find the properity to set to disable a hyperlink column on my aspx form.

I have tried:
1. document.frmPledge.lnkSearch = "";
2. document.frmPledge.lnkSearch.href = "";
3. document.frmPledge.lnkSearch.disabled = true;

Attempt 1 do nothing. No errors, but the link doesn't change either.

Attempts 2 and 3 error out stating that lnkSearch is null or not an object.

What am I missing? Thank you for your help

Jason Meckley
Database Analyst
WITF
 
try this:
Code:
<script language=JavaScript>
function modifyAnchor(bool) {
   anchor = document.getElementById("google");
   if (bool) {
      anchor.value = anchor.href;
      anchor.href = "javascript:void(0)";
   }
   else {
      anchor.href = anchor.value;
   }
}
</script>
<body>
<form name=blahForm>
<a href='[URL unfurl="true"]http://www.google.com'[/URL] id=google>Google</a><br>
<input type=checkbox onclick='modifyAnchor(this.checked)'>Disabled
</form>
</body>

-kaht

banghead.gif
 
Thanks kaht, this is something I have spent long time to figure out. However, can you give me a clue on how I can do this for all href's within a frame(in a loop)?? I want to enable/disable all options for a menu on a certain condition
and have following script now which is called from the 'main' frame to the 'menu' frame:
Code:
function disable() {
var oAllColl = parent.frames[2].document.all;
for (var i= 0; i< oAllColl.length; i++)
if (oAllColl.item(i).disabled == false)
oAllColl.item(i).disabled = true;
}
This works for everything except <a> with Href, for reasons I do not understand, because the link is 'greyed' out, but still it is possible to click it.

Thanks in advance
 
place this code somewhere within the frame that contains the anchors
Code:
function modifyAnchor(bool) {
   var anchors = document.getElementsByTagName("a");
   for (i = 0; i < anchors.length; i++) {
      if (bool) {
         anchors[i].value = anchor.href;
         anchors[i].href = "javascript:void(0)";
      }
      else {
         anchors[i].href = anchor.value;
      }
   }
}

-kaht
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top