Prova questo codice.... che disabilita tutti gli elementi figli di un elemento padre.
codice:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript" type="text/javascript"> <!-- function protect(anObject, protection) { if (anObject == null) { return true; } // if (anObject == null) var members = anObject.children.length; var i = 0; for (i=0;i<members;i++) { var curObject = anObject.children.item(i); if (curObject != null) { protect(curObject,protection); } // if (curObject != null) } // for (i=0;i<=members;i++) anObject.disabled = protection; return true; } // function protect(anObject, protection) //--> </script> </head> <body> <div id="id1"> <input type="text" id="text1" value="45415455054090"> <input type="text" id="text2" value="45415455054090"> <input type="text" id="text3" value="45415455054090"> <input type="text" id="text4" value="45415455054090"> <input type="text" id="text5" value="45415455054090"> </div> <input type="button" value="Protect" onclick="protect(document.getElementById('id1'),true)"> <input type="button" value="Unprotect" onclick="protect(document.getElementById('id1'),false)"> da qui c'è un form <form id="myform" action="" method="post"> <div id="id2"> <input type="text" id="text10" value="45415455054090"> <input type="text" id="text20" value="45415455054090"> <input type="text" id="text30" value="45415455054090"> <input type="text" id="text40" value="45415455054090"> <input type="text" id="text50" value="45415455054090"> </div> </form> i bottoni sono fuori dalla form <input type="button" value="Protect" onclick="protect(document.getElementById('myform'),true)"> <input type="button" value="Unprotect" onclick="protect(document.getElementById('myform'),false)"> </body> </html>

Rispondi quotando