Page 1 of 1

Problem with setonchange for suggest control

Posted: Wed Jul 19, 2017 10:23 pm
by groakes
Hi,

I am having a problem with a setonchange function for a suggest control in a Dynaform.

I have a radio button (additionalCuratorRequired) which, when selected, should show a suggest control (additionalCurator) which executes an SQL query to get a list of users in the Group "Curators"
Code: Select all
select USERS.USR_UID, USR_USERNAME from USERS, GROUP_USER, GROUPWF where USR_USERNAME <> '' and USERS.USR_UID = GROUP_USER.USR_UID and GROUP_USER.GRP_UID = GROUPWF.GRP_UID and GRP_TITLE = 'Curators';
However, when I preview the form it fails to load - I just get the spinning circle.
Code: Select all
function showOrHideAdditionalCurator() {
  if ($("#additionalCuratorRequired").getValue() == 1 ) {
        $("#additionalCurator").show();
      } else {
        $("#additionalCurator").hide();
  }
}

showOrHideAdditionalCurator();
$("#additionalCuratorRequired").setOnChange(showOrHideAdditionalCurator);
I have other setonchange controls that work on this form - I have included the full form as an attachment.

When I comment out the execution line the form loads fine (though obviously the suggest control doesn't appear).
I have replaced the SQL query with a set of options and that hasn't made any difference.
I have also replaced the suggest field with a text field, again to no success.

Any ideas? Is there something I have missed (standard comment here about me not being a programmer)?

thanks
Greg

Re: Problem with setonchange for suggest control

Posted: Thu Jul 20, 2017 9:39 am
by stevensi1018
groakes wrote: $("#additionalCuratorRequired").setOnChange(showOrHideAdditionalCurator);[/code]
You used setOnChange (note the capital letters on 'On' and 'Change') while the function should be setOnchange (note that only 'On' has a capital letter)

See the javascript functions here: http://wiki.processmaker.com/3.0/JavaSc ... etOnchange

Hope that helps, I had the same problem when I started working on my process

Re: Problem with setonchange for suggest control

Posted: Thu Jul 20, 2017 7:53 pm
by groakes
Thanks Steven - Perfect!

Such embarrassment :oops: