PDA

View Full Version : [SOLVED] Checkbox setValue problem



zab
4 Apr 2008, 3:48 AM
Hi,

I have checkbox in a panel (not in a form) and I want to implement a button which check all the checkboxes.
I try with setValue but there is an error on firebug :

myCheckBox.setValue is not a function.

It's very strange because other functions like setVisible (for example) work.

Here the code corresponding on the handler of my button :

function tout_cocher(){
var myCheckBox = Ext.get(document.getElementById('check_id0'));
myCheckBox.setValue(true);

}

it's a test, so it point at only one checkbox.

PS: sorry for my english... :">

4 Apr 2008, 3:57 AM
...

you're going about it the wrong way.

if the Id is static: Ext.getCmp('yourCBId').setValue(true || false)

4 Apr 2008, 4:01 AM
Also, you can store a reference to the checkbox.

Document.getElementById will return the raw HTML element, not the associated component.

zab
4 Apr 2008, 5:37 AM
thanks for your rapidity.

I tried your first solution but I had another error in firebug:

Ext.getCmp("check_id0") has no properties


Also, you can store a reference to the checkbox.

Document.getElementById will return the raw HTML element, not the associated component.

Ok, but I add these checkbox dynamically by createChild. So there isn't any variable to reference the checkbox... :s

4 Apr 2008, 5:39 AM
Ah, so it's a generic HTML element. You can just use document.getElementById('checkboxid').click()


Check the following:
http://www.javascriptkit.com/jsref/checkbox.shtml

zab
4 Apr 2008, 6:01 AM
Great!! it works find! thanks! :D