c# - How can I Enable\Disable all subcontrols of a table? -
I have a checkbox when it is checked that I want to enable a table and its subrules and when If it is disabled then I want to do the opposite.
I have already understood that I have to repeat all the sub-controls in the table, and my question is that there is no good and normal way to do this.
Thanks in advance,
Oz.
You . Suppose your HTML looks like this:
& lt; Input type = "checkbox" onclick = "toggle control (this)" /> Control disabled & lt; Table id = "myTable" & gt; & Lt; TR & gt; & Lt; Td> Name: & lt; Input type = "text" /> gt; & Lt; / Td> & Lt; Td> Select: & lt; Input type = "radio" /> & Lt; / Td> & Lt; / TR & gt; ..... toggle / enable the toggle control () function to enable / disable all controls inside the table ( means all text Box, button, checkbox, radio button, and dropdown ) looks like this:
& lt; Script & gt; Function Toggle Control (E) {$ ('# myTable input, select, textarea'). Ether ('disabled', e.check); } & Lt; / Script & gt; The jQuery CSS selector can enable / enable a line enable / possible control. With plain old javascript, this task will look like this:
var myTable = document.getElementById ("myTable"); Var control = myTable.getElementsByTagName ("Input"); // Repeat the previous row for "Choose" and "Texture" (i = 0; i & lt; controls.length; i ++) {control = controls [i]; Control.disabled =! Control.disabled; }
Comments
Post a Comment