CheckBox Checked by JavaScript

Use this board to ask questions or have discussions with other Rich Displays users.
Post Reply
k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

CheckBox Checked by JavaScript

Post 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
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: CheckBox Checked by JavaScript

Post 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.
k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

Re: CheckBox Checked by JavaScript

Post 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 2185 times
My Screen :
qddssrc.test.txt
(3.5 KiB) Downloaded 271 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 2185 times
Do you have a solution ?
Thank you and have a nice week-end
k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

Re: CheckBox Checked by JavaScript

Post by k2R400 »

up
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: CheckBox Checked by JavaScript

Post 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;

k2R400
Profound User
Posts: 62
Joined: Sat Feb 18, 2012 12:03 pm
First Name: Patrick
Last Name: THOMAS
Company Name: Oo2
Country: France
Contact:

Re: CheckBox Checked by JavaScript

Post by k2R400 »

Thanks you very much, it's work now !
User avatar
David
Profound Logic Staff Member
Posts: 690
Joined: Fri Jan 04, 2008 12:11 pm
First Name: David
Last Name: Russo
Company Name: Profound Logic Software
Contact:

Re: CheckBox Checked by JavaScript

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests