Not really. I have a bunch of links inside the DIV. Then another DIV a lot like this one.
I need a more generic solution.
Main Topics
Browse All TopicsI am using the "related solution" to toggle the editability of the input fields inside a DIV when I check/uncheck a box.
But I really need the JavaScript links in the DIV to disable/enable.
Example link: <a href="#" onclick="SetCalendars('D')
How would I do that?
The code in the other solution that actually finds the input fields and disables them is attached.
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.
Looks like I'm completely on the wrong path:
http://radio.javaranc
I guess I need to cover the DIV with a translucent one to prevent the clicks ...
Does that sound right?
Hi,
Here is the generic solution....
//////////////////// JS code starts /////////////////////
<script language="javascript" type="text/javascript">
var setOfLinksOnclickAction = new Array();
function DisableLinks(someDivId)
{
//Getting Target Div to disable all the links inside it.
var targetDiv = document.getElementById(so
//Getting all the archorList in the div
var anchorList = targetDiv.getElementsByTag
for (var i=0; i < anchorList.length;i++)
{
//Making sure that end-user identifies(sees) that the link is disabled
anchorList[i].disabled=tru
//Storing the link-onclick action in global variable which will be used in EnableLinks(...) function
setOfLinksOnclickAction[i]
//Real-Disabling
anchorList[i].onclick = '';
}
}
function EnableLinks(someDivId)
{
//Getting Target Div to disable all the links inside it.
var targetDiv = document.getElementById(so
//Getting all the archorList in the div
var anchorList = targetDiv.getElementsByTag
for (var i=0; i < anchorList.length;i++)
{
//Making sure that end-user identifies(sees) that the link is disabled
anchorList[i].disabled=fal
//Storing anchor's original value for onclick functionality
anchorList[i].onclick = setOfLinksOnclickAction[i]
}
}
</script>
////////////////////// JS code ends //////////////////////////
And please see the attached your HTML file with the integration. (Remove txt extenstion)
If you opt for the div approach you can try this example which I modified from:
http://www.hunlock.com/blo
There's some cruft in there for example purposes, such as padding, you can remove that of course, and the links to call enable() / disable() as you will know when to call those yourself.
Thanks for accepting the solution... but wait... the provided solution gets broken if you have multiple-divs and you wanna enable/disable any of the div.
So here comes new JS code... Now, its truly generic..:))) (For your ref. html file is also attached)
You dont have to change your HTML code. As the JS-function name are same as well as input parameters are also same.
You just need to add one additional javascript call on body-onlod..
<body onload="javascript:Set2DAr
//////////////////////////
<script language="javascript" type="text/javascript">
/*************************
Following ARRAY is the jagged array...
Where,
arr(n) = div
arr(0)(n) = all the onclick method call of href.
**************************
var setOfLinksOnclickAction = new Array();
//This function should be called on body-onload
function Set2DArrayOfDivs()
{
//Getting All the divs
var allDivs = document.getElementsByTagN
for (var i=0; i < allDivs.length;i++)
{
//Getting all the hrefs in the div
var anchorList = allDivs[i].getElementsByTa
//Setting the array length to the number of hrefs
setOfLinksOnclickAction[i]
for (var j=0; j < anchorList.length;j++)
{
//Storing the onclick text in the jagged array.
setOfLinksOnclickAction[i]
}
}
}
function DisableLinks(someDivId)
{
//Getting Target Div to disable all the links inside it.
var targetDiv = document.getElementById(so
//Getting all the archorList in the div
var anchorList = targetDiv.getElementsByTag
for (var i=0; i < anchorList.length;i++)
{
//Making sure that end-user identifies(sees) that the link is disabled
anchorList[i].disabled=tru
//Real-Disabling
anchorList[i].onclick = '';
}
}
function EnableLinks(someDivId)
{
//Gettin all the divs in the document
var allDivs = document.getElementsByTagN
for (var i=0; i < allDivs.length;i++)
{
//if input div is the one to enable it again
if(allDivs(i).getAttribute
{
//Getting all the hrefs
var anchorList = allDivs(i).getElementsByTa
for (var j=0; j < anchorList.length;j++)
{
//Enabling link for "Click-Ability"
anchorList[j].disabled=fal
//Storing anchor's original value for onclick functionality from jagged array
anchorList[j].onclick = setOfLinksOnclickAction[i]
}
}
}
}
</script>
//////////////////////////
Business Accounts
Answer for Membership
by: jb1devPosted on 2009-11-04 at 15:54:37ID: 25745478
Would something like this work for you?
Add ids to your anchor tags then use getElementById() and assign or remove the onclick property?
Select allOpen in new window