Click to See Complete Forum and Search --> : Disable entire span tag and inputs inside


PisgahMan
03-22-2003, 09:13 PM
If you have a span tag with several tables in it can you disable the span so that all the elements inside are disable? If not can you get a list of the elements inside a span tag? I need it to be disabled, not just hidden. Thanks

dabush
03-22-2003, 09:55 PM
what do you mean by disabled? if you want it gone forever, do, idname.innerHTML = ''; What is wrong with hiding it?

PisgahMan
03-22-2003, 10:32 PM
Hiding won't work, I need each field inside the span to be disabled=true

dabush
03-22-2003, 11:54 PM
ah...i see...only form elements, right?

dabush
03-23-2003, 12:39 AM
to disable form elements in a span, call the function
disableElements(spanid) and put the id of the span as the
parameter. for example, if you have <SPAN ID=myspan>...,
then call the function as disableElements(myspan). you get
the picture. then all you do, is put the following in the <HEAD></HEAD> section of your code.

<script language=JavaScript type=text/javascript>
<!--
function disableElements(thespan)
{
var tempName = 0;
var tempChar = 0;
while (thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<input') != -1)
{
tempName++;
thespan.innerHTML = thespan.innerHTML.substring(0,(thespan.innerHTML.substring(0,tempChar).length + thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<input') + 6)) + ' name=disablescript'+tempName.toString() + thespan.innerHTML.substring((thespan.innerHTML.substring(0,tempChar).length + thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<input') + 6),thespan.innerHTML.length);
tempChar = thespan.innerHTML.substring(0,tempChar).length + thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<input') + 1;
}
var tempChar = 0;
while (thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<select') != -1)
{
tempName++;
thespan.innerHTML = thespan.innerHTML.substring(0,(thespan.innerHTML.substring(0,tempChar).length + thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<select') + 7)) + ' name=disablescript'+tempName.toString() + thespan.innerHTML.substring((thespan.innerHTML.substring(0,tempChar).length + thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<select') + 7),thespan.innerHTML.length);
tempChar = thespan.innerHTML.substring(0,tempChar).length + thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<select') + 1;
}
var tempChar = 0;
while (thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<textarea') != -1)
{
tempName++;
thespan.innerHTML = thespan.innerHTML.substring(0,(thespan.innerHTML.substring(0,tempChar).length + thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<textarea') + 9)) + ' name=disablescript'+tempName.toString() + thespan.innerHTML.substring((thespan.innerHTML.substring(0,tempChar).length + thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<textarea') + 9),thespan.innerHTML.length);
tempChar = thespan.innerHTML.substring(0,tempChar).length + thespan.innerHTML.toLowerCase().substring(tempChar,thespan.innerHTML.length).indexOf('<textarea') + 1;
}
for (var loop = 1; loop <= tempName; loop++)
{
document.getElementById('disablescript'+loop).disabled=true;
}
}
// -->
</script>