Check the value of a checkbox

Check the value of a checkbox

  
I'm trying to use the extended properties of a checkbox so that when it is selected, it sets several items to read only, and when it is unchecked, it sets them back to normal fields. I've got the checkbox running the JavaScript when it is clicked, but I can't seem to get the system to check whether or not the checkbox is selected or not. This is preventing me from building an if statement that will allow me to differentiate when to change field properties.

The only information I've been able to find online for checking the value of a checkbox is to use the following command: if (document.form.field.checked == true). The problem I'm running into is that the page doesn't use a form tag, so I'm at a loss as to what information to use for this command. I've tried using the page name (which gave me: document.DRG_CRF2_Edit.neuro_same_as_above.checked) but it doesn't seem to read that. On the other hand, if I run document.getElementById("wtDRG_CRF2_neuro_same_as_above").value, I just get the work on regardless. Any help in this matter would be greatly appreciated. Thanks

Josh
Hi Joshua,

To access a DOM object with javacript in an OutSystem web screen, you should use the OutSystems RuntimeId property of the web widget that you want to access (this returns the DOM Identifier of the widget). To have access to this RuntimeId, you have to fill in the Name property of your checkbox widget (see the CheckBox widget properties in the Service Studio online help). Also, I think you would rather use the onchange extended property of the widget.

See the example below.



Best Regards,

Daniel Lourenço
OutSystems

Daniel,

Thanks for the help.  I was able to get the system to verify whether the checkbox was selected or not.  Thank you.

Josh
Very interesting topic. Though I don't know the way to solve this question, I know the checkbox state is the key to solve this problem. Don't know if you'd fixed it or not. Among all the C# button controls, I feel most curious about the checkboxes. This is a good question.