Issue with CheckBox Selection and Function Error in tmswebcore

Dear Support Team,

I am currently encountering a challenge while working on a project utilizing tmswebcore. The issue arises when I attempt to select multiple elements, specifically checkboxes, that share the same classname. My objective is to gather the checked checkboxes into a string list and subsequently add these selected elements to another list. However, during this process, I am encountering an error that states: "Uncaught TypeError: checkBox.GetChecked is not a function."

Could you kindly provide assistance or guidance on how to resolve this issue? Your expertise and support in this matter would be greatly appreciated.

Thank you for your time and assistance. I look forward to your prompt response.

Error SS:


Demo: (8.5 KB)

Best regards.

You cannot just cast a TWebCheckBox to a DOM checkbox element:

CheckBox := TWebCheckBox(checkBoxes[I]);

If you want to access this DOM element as a TWebCheckBox, you should create an instance of the checkbox class mapped on the unique element ID of this DOM element (via checkbox := TWebCheckBox.Create(elementid));

Dear Bruno,

Thank you for your previous guidance. However, I am still facing challenges with accessing the DOM element's checked value. The primary issue seems to stem from the instance creation of the element. When I create an instance of the checkbox, it appears to revert to its default value. As a result, checkboxes that were previously checked are now being displayed as unchecked. This issue is preventing me from accurately retrieving the checked checkboxes.

I have included screenshots for a clearer understanding of the problem I am encountering.


Given this situation, I am considering an alternative approach. Would it be feasible to create the checkboxes and store them in a List of object <TWebCheckbox>? Additionally, is there a method similar to QuerySelector that would allow me to retrieve created TWebCheckboxes with the same classname? This would potentially enable me to directly access the checked values without the current complications.

Your expertise and further assistance in resolving this issue would be greatly appreciated. I look forward to your suggestions or any alternative methods you might recommend.

Thank you once again for your support and time.

Best regards.

When you create a checkbox, its default state is Checked = false.
So, typically, one creates this checkbox with this default state at startup and AFTER this, can always get the state when the user would have clicked a checkbox.
So, in a nutshell, create these checkboxes at form initialization when the default expected checked state is false anyway.