Recent

Author Topic: creating two items in one panel  (Read 2699 times)

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
creating two items in one panel
« on: June 17, 2020, 04:23:41 pm »
I want to create two items in one panel. That's not a problem.
Code: Pascal  [Select][+][-]
  1. constructor TDemoform.create;
  2. begin
  3.   Panel  :=document.createElement('div');
  4.   Panel['class']:='panel panel-default';
  5.   item1 :=document.createElement('input');
  6.   item1['id']:='tekst1';
  7.   item1['type']:='text';
  8.   item2 :=document.createElement('input');
  9.   item2['id']:='tekst2';
  10.   item2['type']:='text';
  11.   document.body.appendChild(panel);;
  12.   Panel.appendChild(item1);
  13.   Panel.appendChild(item2);              
  14.  
When I run this code I see two text input items next to each other.
If I create two items in HTML, tag <BR> creates a new line after the first item.

Is it also possible to do this in pas2js or do I have to create a panel for each item?

I never build forms in javascript directly.
 
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

PascalDragon

  • Hero Member
  • *****
  • Posts: 6403
  • Compiler Developer
Re: creating two items in one panel
« Reply #1 on: June 17, 2020, 04:44:47 pm »
You should be able to simply do a br := document.createElement('br') and do a Panel.AppendChild(br) at the correct position you want.
Though in general the idea is to use CSS for such things nowadays. ;)

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: creating two items in one panel
« Reply #2 on: June 18, 2020, 08:37:32 am »
Your right. It's just an element. Is it possible to make a CCS in lazarus?
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

PascalDragon

  • Hero Member
  • *****
  • Posts: 6403
  • Compiler Developer
Re: creating two items in one panel
« Reply #3 on: June 18, 2020, 09:24:10 am »
Is it possible to make a CCS in lazarus?

Just create a CSS file and reference it from your HTML file? Alternatively you can also use inline styles. That is used extensively in Pas2JS_Widget like here.

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: creating two items in one panel
« Reply #4 on: June 18, 2020, 09:26:33 am »
Never mind. I created an text file in the editor. Put some styles into it and saved to css. Then linked the stylesheet file into the html of the project.

For me it has been a long time when i used js/html/css :D
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

 

TinyPortal © 2005-2018