PDA

View Full Version : Disable Form Input Java Question



sflwebguy
07 Oct 2010, 09:12 AM
I'll try to be blunt and not draw this out...

I have a form and i have it set up to disable certain form elements when a radio button is picked. Only problem I have is our other developer has our "Error" message set up to, what it seems, refresh the page and then show the error.

When this happens the radio button that was clicked and turns disables stuff does stay clicked but input fields are no longer disabled allowing the user to now use those fields which is a no no.

Take a look at the java and if anyone has any idea as to why this happens or knows a better fix let me know.

<script type="text/javascript">
function toggleAlert() {
toggleDisabled(document.getElementById("lala"));
toggleDisabled(document.getElementById("lala2"));
}
function toggleDisabled(el) {
try {
el.disabled = el.disabled ? false : true;
}
catch(E){
}
if (el.childNodes && el.childNodes.length > 0) {
for (var x = 0; x < el.childNodes.length; x++) {
toggleDisabled(el.childNodes[x]);
}
}
}
</script>