Page 1 of 1

checkboxes

Posted: Fri May 05, 2017 12:12 pm
by dkmccammon
I have tried to write a function for checkboxes, but it's not working.

This is what I wrote:

function handleCheck(check, field) {
var checkbox = document.getElementsByClassName("checkBoxes").checked;
pui.set(field,checkbox);

}

Then in the Genie on the Onclick Event I put handleCheck("Y", "I_3_26_W2");
where I_3_26_W2 is where the value Y needs to be placed or N if the checkbox is not checked.
I have set the initialization value to "N".

Can you please assist me in the best way to approach checkboxes? I tried searching the forums for the checkboxes but didn't find anything.

Re: checkboxes

Posted: Fri May 05, 2017 12:31 pm
by dkmccammon
Please disregard, I found the solution.

Re: checkboxes

Posted: Fri May 05, 2017 6:25 pm
by Scott Klement
I'm glad you found a solution. For the benefit of other people who read these forums, can you show us what you did?

My understanding of this routine is that it should set a checkbox to either Y or N (I'm assuming these are the values of the checked/unchecked value properties of the checkboxes?) If so, I would expect the routine to be as simple as this:

Code: Select all

function handleCheck(check, field) {
  pui.set(field,check);
}
But, the fact that you have written code to retrieve an array of all HTML elements that contain the "checkBoxes" CSS class makes me wonder if I'm misinterpreting what you're trying to do. Obviously the code wasn't right (adding .checked to the getElementsByClassName doesn't make any sense, and setting one field on the screen to the array of all checkboxes doesn't make any sense.) But I can't tell what the right solution would be, because I'm not sure that I understand what the routine is supposed to do.

Since you have a solution, maybe you could just post it for other people to learn from?

Re: checkboxes

Posted: Mon May 08, 2017 2:14 pm
by dkmccammon
Sure... for my situation I changed field type of the previous element (output field) to a checkbox field type and ensured that the checked value was 'Y' and the unchecked value was 'N'. However, dragging a checkbox from the widgets and trying to tie that into the screen did not work.