Is it possible to set the id for a html tag (div) which you have ‘declared/defined’ in the IDE through a TWebHTMLDiv? Setting the ElementID property does not work, since I thought this would try to map the code on the already existing id in the html. But I want to insert a div with a name that I control. Adding code to the HTML property of the TWebHTMLDiv element like
also does not do the job, since the elements you created ‘under/as part of’ this div in the IDE then will not show up.
In other words: I want the resulting HTML of the TWebHTMLDiv to be:
// Inner HTML here
I think parts of your message became unreadable because you need to use the </> style around any HTML you would insert here (see toolbar on this message editor).
New information (i start understanding what is happening)
It is hard to explain what is happening. So let met try to tell you what I want and perhaps you can give me a hint how to do that
(What happened is that I got the HTML from a different form).
I have a ‘base-form’ which has all the logic to fill the screen and send the data to a REST server.
This base form has a TWebHTMLDiv called ‘Inhoud’ where the inheriting forms should put their controls.
All detailed forms are derived from this form. Only one detailed form can be loaded at any time (I have a SPA application).
Now I want a generic function in the base form that can enable/disable all input fields in the form. So that would be something like:
asm
var frame = document.getElementById('invoerscherm');
if (!frame) return;
// READONLY voor tekstvelden
frame.querySelectorAll('input, textarea')
.forEach(el => el.readOnly = AReadOnly);
// .forEach(el => {
// if (el.type !== 'checkbox' &&
// el.type !== 'radio' &&
// el.type !== 'file' &&
// el.type !== 'range')
// {
// el.readOnly = AReadOnly;
// }
// });
// DISABLED voor selects
frame.querySelectorAll('select')
.forEach(el => el.disabled = AReadOnly);
end;
And now the question: How do I get the correct HTML element, when I cannot set the ID because I have multiple descandants? Can I set a ‘dedicated’ property for this in the TWebHTMLDiv? How?
I tried to set the ElementID (uniquely; i.e. id=”[objecttype]invoerscherm) on the derived class. But then the element-id is not part of the HTML. Is that a bug?
I’m afraid I still do not really understand what you are doing here.
I understand there is somewhere a HTML DIV element in a form template and this DIV element should host controls. I see no information on how the controls that should be hosted in this DIV are created, i.e. whether these is also based on HTML elements on which a control is supposed to be mapped, or whether these are directly created TMS WEB Core controls. If these are directly created TMS WEB Core controls, you should be able to access these from your Pascal code without needing an ElementID.
Again, the ElementID is just the 1:1 link between a HTML element and a Pascal class control. The purpose of the link is to map a Pascal class on a HTML element. That is the only purpose.The ElementID is not provided to control the ID for a HTML element that gets created. If you want to know the ID of the automatically created HTML element for a control, you can get it via:
control.ElementHandle.id;
If you want from your base form to perform an enable/disable of all controls that get inserted into a DIV, it will depend on how these controls will be created.
Thanks for your reactions. I solved it by putting an extra class name in the list. Then selecting all elements with that classname and disabling them.
Issue can be closed.