Page 1 of 1

CheckBox Checked by JavaScript

Posted: Thu Nov 07, 2013 4:33 am
by k2R400
Hello,

I have a check box with an indicator for the return value.
If i check it manualy, after a submit(), the return value is *ON in my program : it's OK.
Now if it's checked by a JS function like below, then return value is *blanks after a submit() !!!!
Into an OnChange Element :

Code: Select all

  var box = document.getElementById("MyCheckBox");  
  box.checked=true;
Do you know why ?

Thank you in advance

Re: CheckBox Checked by JavaScript

Posted: Thu Nov 07, 2013 3:13 pm
by Scott Klement
What the 'checked' attribute determines what is shown on the display (i.e. is the checkbox checked or unchecked.)

However, what gets sent to your RPG program is what is in the "checked value" or "unchecked value" attributes of the checkbox widget. So if you're looking to get *ON or *OFF in the RPG program, make sure the "checked value" is set to 1, and "unchecked value" is set to 0.

Re: CheckBox Checked by JavaScript

Posted: Fri Nov 08, 2013 1:45 pm
by k2R400
Scott,

Thank you.
But the "checked value" is set to 1, and "unchecked value" is set to 0.
Test2.png
Test2.png (12.06 KiB) Viewed 2195 times
My Screen :
qddssrc.test.txt
(3.5 KiB) Downloaded 272 times
Sample Program :

Code: Select all

     h DftActgrp(*no)
     FTEST      CF   E             WORKSTN
      /COPY QCOPY,HANDLER
      /Free
         Exfmt F1;
         Result = 'Result : <' + CheckOrNot + '>';
         Exfmt F2;
         *InLr = *On;
Test.png
Test.png (9.9 KiB) Viewed 2195 times
Do you have a solution ?
Thank you and have a nice week-end

Re: CheckBox Checked by JavaScript

Posted: Wed Nov 13, 2013 11:54 am
by k2R400
up

Re: CheckBox Checked by JavaScript

Posted: Wed Nov 13, 2013 1:45 pm
by David
I think I see the problem here. Profound UI has a 'modified' flag on all widgets. It will only send values to the server for components that are seen to be modified by the user. So, it's not seeing the change made by your script.

You can set the modified flag like this:

Code: Select all


  var box = document.getElementById("MyCheckBox");  
  box.checked=true;
  box.modified=true;


Re: CheckBox Checked by JavaScript

Posted: Wed Nov 13, 2013 2:41 pm
by k2R400
Thanks you very much, it's work now !

Re: CheckBox Checked by JavaScript

Posted: Wed Nov 13, 2013 4:15 pm
by David
Great! We were thinking that there should be an easier way to do this -- you can adjust most widgets through scripting using our "changeElementValue()" and "pui.set()" APIs. These set the modified flag internally so that you don't have to worry about it.

As it stands, these APIs don't work with checkboxes. However, we have updated them for the next release so that they can be used by passing either a true/false value to check/uncheck, or a value matching the 'checked value' property.