Atozed Forums
add attr in input tag - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: add attr in input tag (/thread-3102.html)



add attr in input tag - raulevm - 03-29-2023

I would like to add from Delphi the data-role attribute with the value "checkbox" in the input tag of an IWCheckBox. I was only able to create it in the span tag, but I need to put it in the input tag

Code:
procedure TFrmMain.IWCheckBox1HTMLTag(ASender: TObject; ATag: TIWHTMLTag);
begin
ATag.AddStringParam('data-role', 'checkbox');
end;
Code:
<span class="IWCHECKBOX1CSS" data-role="checkbox" data-type="IWCHECKBOX" id="IWCHECKBOX1">
<input id="IWCHECKBOX1_CHECKBOX" name="IWCHECKBOX1_CHECKBOX" type="CHECKBOX">
<span id="IWCHECKBOX1_CHKBCAPTION">IWCheckBox1</span></span>

I wish it was like this


Code:
<span class="IWCHECKBOX1CSS" data-type="IWCHECKBOX" id="IWCHECKBOX1">
<input id="IWCHECKBOX1_CHECKBOX" data-role="checkbox" name="IWCHECKBOX1_CHECKBOX" type="CHECKBOX">
<span id="IWCHECKBOX1_CHKBCAPTION">IWCheckBox1</span></span>



RE: add attr in input tag - jeroen.rottink - 03-29-2023

Code:
procedure TIWForm1.dbCheckBoxHTMLTag(ASender: TObject; ATag: TIWHTMLTag);
var
  InputTag: TIWHTMLTag;
begin
  InputTag := ATag.Contents.FindTagByName('input') as TIWHTMLTag;
  // or InputTag := ATag.Contents[0] as TIWHTMLTag;
  InputTag.AddStringParam('data-role', 'checkbox');
end;