Set Check-box from button click

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Hubbaroo
Posts: 60
Joined: Sat Sep 21, 2013

11 Sep 2015

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

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

14 Sep 2015

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.

Hubbaroo
Posts: 60
Joined: Sat Sep 21, 2013

18 Sep 2015

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

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

22 Sep 2015

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

Hubbaroo
Posts: 60
Joined: Sat Sep 21, 2013

22 Sep 2015

I sent the file after following your instructions.

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

23 Sep 2015

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).

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 17 guests