Page 1 of 1
Set Check-box from button click
Posted: 11 Sep 2015
by Hubbaroo
When I ckick the check-box the change function works. When I set the value from a button on-click the check-box changes but the change event does not fire? Maybe I'm doing it wrong?
Thanks
Re: Set Check-box from button click
Posted: 14 Sep 2015
by rostislav
Instead of using fd.field(...).value(), use:
Code: Select all
fd.field('checkbox').control()._el().find('tr input').eq(1).click()
Where 'checkbox' is the internal name of the checkbox control and 1 in eq(1) is the index of the checkbox in the checkbox control that you want to select/unselect. click() is effectively the same as clicking the checkbox with your mouse.
Re: Set Check-box from button click
Posted: 18 Sep 2015
by Hubbaroo
This is what I have in the button on click:
fd.field('DTProjectNumberRequested').value('1');
fd.field('DTProjectNumberRequested').control()._el().find('tr input').eq(1).click();
alert('Hello');
The checkbox gets checked, the checkbox's on click event does not fire, the alert does pop up. Thanks again, it's the easy things sometimes.
Hubbaroo
Re: Set Check-box from button click
Posted: 22 Sep 2015
by rostislav
Having this code in the JS editor:
Code: Select all
fd.field('DTProjectNumberRequested').change(function(){
alert('clicked');
});
And this code in the button onclick handler:
Code: Select all
fd.field('DTProjectNumberRequested').control()._el().find('tr input').eq(1).click();
Works. I have just tested it on my machine. If it doesn't work for you: -check the InternalName is correct (it's not nesessarily the same as the caption for your checkbox control. check it under 'InternalName' in the property grid in Forms Designer for you control) -check console for any JS errros. If you get exceptions in your code it may stop your handler from attaching for example (F12 -> console to bring up the console, depending on the browser). -if the problem still persists, send us the html of your page to
support@spform.com
Re: Set Check-box from button click
Posted: 22 Sep 2015
by Hubbaroo
I sent the file after following your instructions.
Re: Set Check-box from button click
Posted: 23 Sep 2015
by rostislav
Please use the following code:
Code: Select all
fd.field('DTProjectNumberRequested').control()._el().find('span input').eq(0).click();
(I assumed you were using a multiple checkbox control, not boolean).