I must also have added that I have added the following text ,
objSelect[i].style.color = "gray"; objSelect[i].style.cursor = "text"; I still get the blue color on the text. How can I avoid this ?
Main Topics
Browse All TopicsI have a control which by default would be a href once data gets loaded. But if users check one select box I need to disable the hyperlink. How can I disable the link ? I am graying it out by the below code but I need to disable it.
if(radPrefMethod[0].checke
objSelect[i].style.color = "blue";
objSelect[i].style.cursor=
}
else
{
objSelect[i].style.color = "gray";
objSelect[i].style.cursor = "text";
}
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Use a stylesheet and assign a disabled style to the link; for example:
CSS
a.disabled:hover,
a.disabled:visted,
a.disabled:active,
a.disabled {
color: gray;
cursor: text;
text-decoration: none;
}
JS
if(radPrefMethod[0].checke
objSelect[i].className = ""
}
else
{
objSelect[i].className = "disabled"
}
function checkIfEnabled() {
if(radPrefMethod[0].checke
return false; //don't do default action; i.e. don't load href
}
else
{
return true; //do default action; i.e. load href
}
}
HTML
<a href="url" onclick="return checkIfEnabled();">text</a
I am assuming the you have not styled the enabled link. If you did, then assign the appropriate class name.
Well, I shooting in the dark not seeing all the relevant code, but if you use CSS to style a link and use the pseudo classes that should result in the desired appearence.
I'm assuming that "objSelect[i]" is a reference to that "a" element that is to look disabled and there are no CSS styles that override the class being assigned. A style that has a more specific selector will override a style with a less specific selector.
The following demonstration code does what you are asking. Make a new page with copy-and-past and try it out.
<html>
<head>
<title>test</title>
<style type="text/css">
a.disable,
a.disable:active,
a.disable:visited,
a.disable:link,
a.disable:hover {
color: #cccccc;
text-decoration: none;
}
</style>
<script type="text/javascript">
var linkDisabled = false;
function checkIfEnabled() {
if(linkDisabled){
return false;
}
else
{
return true;
}
}
function disableLink() {
var t = document.getElementById("t
if (linkDisabled) {
t.className = "";
linkDisabled = false;
}
else
{
t.className = "disable";
linkDisabled = true;
}
}
</script>
</head>
<body>
<a href="http://www.google.co
id="test">long test text</a><br /><br />
<a href="#nogo" onclick="disableLink();">D
</body>
</html>
This is proof of concept. Your page may have styles that are overriding; for example a style using the link's id will override a style using a class.
Business Accounts
Answer for Membership
by: ljo8877Posted on 2007-02-15 at 06:56:34ID: 18540492
<a href="url" onclick="return checkIfEnabled()">text</a>
d){
function checkIfEnabled() {
if(radPrefMethod[0].checke
return false; //don't do default action
}
else
{
return true; //do default action
}
}