何らかの処理中に入力を抑制したい場合のロジック。
Javascript版です。
以下のようなかんじ。
[disable押下時]
id=”client”配下の入力コントロールを一括でdisableにします。

[undo押下時]
id=”client”配下の入力コントロールを一括でdisable解除します。

ソースは以下。
5 | < title >disable test</ title > |
6 | < script type = "text/javascript" > |
7 | function disable_children_controls(win, b) { |
8 | for(var w of win.children) { |
9 | if(w.disabled != undefined) |
11 | disable_children_controls(w, b); |
18 | < div >< label >Enter something</ label >< input type = "text" >< input type = "button" value = "go !" onclick = "alert('hello !')" ></ div > |
19 | < div >< input type = "checkbox" >A< input type = "checkbox" >B< input type = "checkbox" >C < input type = "radio" checked>X< input type = "radio" >Y< input type = "radio" >Z</ div > |
20 | < div >< input type = "button" value = "disable" onclick = "disable_children_controls(document.getElementById('client'), true)" ></ div > |
23 | < div align = "left" >< input type = "button" value = "undo" onclick = "disable_children_controls(document.getElementById('client'), false)" ></ div > |