PDA

View Full Version : Set/Unset all checkboxes


vik001
07-27-2005, 02:00 PM
<view name="p1" layout="axis:x">
<checkbox id="hrsView1" text="1 am" value="0"/>
<checkbox id="hrsView2" text="2 am" value="0"/>
<checkbox id="hrsView3" text="3 am" value="1"/>
<checkbox id="hrsView4" text="4 am" value="0"/>
<checkbox id="hrsView5" text="5 am" value="0"/>
<checkbox id="hrsView6" text="6 am" value="0"/>
<checkbox id="hrsView7" text="7 am" value="0"/>
<checkbox id="hrsView8" text="8 am" value="0"/>
<checkbox id="hrsView9" text="9 am" value="0"/>
<checkbox id="hrsView10" text="10 am" value="0"/>
<checkbox id="hrsView11" text="11 am" value="0"/>
<checkbox id="hrsView12" text="12 pm" value="0"/>
</view>

I want to have a link where onclick, all the checkboxes should toggle from on to off and viceversa.

Instead of going hrsView1... hrsView12.setAttribute('value',1) and back, I am trying to put it in a for loop, but for some reason its not working.

<text text="Select all">
<method event="onclick">
for (i=1;i&lt;25;i++){
var cbox ='hrsView'+i;
Debug.write(cbox);
cbox.setAttribute('value',1);
}
</method>
</text>

This does not seem to work. Any ideas?

Thanks.

V./

Schlabbermaul
07-27-2005, 11:19 PM
hello!
i think i had the same problem. it doesn't work bacause laszlo thinks that "var cbox" is not your object but it is a string. i don't know how to do it right :( solution? anyone?

mmenti
07-28-2005, 04:11 AM
Something like the below (in your onclick event) should work:

for (i=0; i < 12; i++) {
p1.subnodes[i].setValue(1);
}

vik001
07-28-2005, 06:08 AM
That worked. awesome! thanks.


<!DOCTYPE canvas SYSTEM "http://www.laszlosystems.com/lps/tools/lzx.dtd">
<canvas width="100%" height="100%" debug="true">
<simplelayout></simplelayout>
<view name="p1" layout="axis:x">
<checkbox id="hrsView1" text="1 am" value="0" />
<checkbox id="hrsView2" text="2 am" value="0" />
<checkbox id="hrsView3" text="3 am" value="1" />
<checkbox id="hrsView4" text="4 am" value="0" />
<checkbox id="hrsView5" text="5 am" value="0" />
<checkbox id="hrsView6" text="6 am" value="0" />
<checkbox id="hrsView7" text="7 am" value="0" />
<checkbox id="hrsView8" text="8 am" value="0" />
<checkbox id="hrsView9" text="9 am" value="0" />
<checkbox id="hrsView10" text="10 am" value="0" />
<checkbox id="hrsView11" text="11 am" value="0" />
<checkbox id="hrsView12" text="12 pm" value="0" />
</view>
<text text="Select all">
<method event="onclick">
for (i=0; i &lt; 12; i++) {
p1.subnodes[i].setValue(1);
}
</method>
</text>
</canvas>