473,662 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Any easy way to add dynamic elements

13 New Member
Hello,

I am new to JS and DHTML. I want to add elements like lable, textbox, button etc on differnt events of the page in a div present in html page.
So, the contents of present div element changes accordingly. At present, I am adding each element in a form & the dynamic form in the div. I am unable to add the form directly, so i have a label in html div & add the form using insertBefore ('dynamicForm', lbl).

Expand|Select|Wrap|Line Numbers
  1.  
  2.    <div id="directDIV" class="directDIV" style="width: 273px; position: absolute; height: 550px; background-color:silver; left: 13px; top: 188px;"> 
  3.         <label id="lbl"></label>
  4.     </div>
  5.  
Now, in another event, again i got to create another form & add in the div. But for that I first got to remove all elements from the div, if any. Then add the new created form. But as i am not able to add form directly using appendchild('ne wform'). And if I delete all elements than the original alble is also deleted & hence can't use insertBefore().

How do i face and solve this situation. By removing and adding or appending elements in the html div on different events.

Any help is highly appreciated. Please help me to solve this problem.

Thanks
Trupti
May 15 '07 #1
1 1574
gits
5,390 Recognized Expert Moderator Expert
hi ...

can you tell me what's getting wrong when you try to append your form with:

Expand|Select|Wrap|Line Numbers
  1. // we assume that elementtoappend is a ref to your form
  2. var desiredelement = document.getElementById('directDIV');
  3. desiredelement.appendChild(elementtoappend);
  4.  
if you want to use insertBefore your label, than you mustn't remove your label with id='lbl' ... so during your remove operation you should ask for the id of the element to be removed and if that id equals 'lbl' don't remove it ...

ps: i'm working on the other problem you had with adding elements a generic/reliable way ... without browserdetectio n ... you remember it? be patient ... i have a lot to do at the office this week ... weekend will come and a solution too ;)
May 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2822
by: Vasileios Zografos | last post by:
Hello, I have a function that generates some values (e.g. vertices in 2d space) the number of which I dont know. So, it could generate 20 vertices, 100 vertices, or even 1 vertex. void generateVals() { ..... //generate some values
4
2135
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see "TAG#") when more than 1 number (see "VLANS") is inputed into my form. QUESTION: How do I make my dynamic form have a dynamic input box(which is created by checking the checkbox and calling the functionC1) inside it and still be able to pass the...
14
476
by: chai | last post by:
Can anyone help me in finding elements stored in a dynamic array in.
7
3576
by: Venus | last post by:
Hello, I am trying to generate a dynamic form at runtime and would like to do it using "<asp: ..." form elements as follows Build up the string that is placed somewhere in the HTML code the same way like regular input fields can. strForm = "<form name=""myForm"" runat=""server"">" & vbCrLf strForm += "<asp:button name=""myName"" .... runat=""server"" />" & vbCrLf
4
3303
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just for the controls and not for the form itself. What I am trying to achieve is to create an entire form (including controls)
0
1487
by: Venus | last post by:
Hello, After trying some ways to do it I wanted to use something like the code below but for some reason is not working (I have to generate the entire form dynamically (not only the controls)): Can anyone make any suggestions on how to do it ? Thanks
1
1787
by: curiousEngine | last post by:
how to make provision of a dynamic array say of size 5 with each slot holding a structure of type passenger? /* * Labsheet Queues Question 1 Implement a program that shows a queue of people lining at a bus-stop. The first one in the queue is the first one to get on the bus. Your program should display the following data : Id
2
8952
by: Damir | last post by:
Hello! I have noticed that after (sucessfully) executing the command: FLUSH PACKAGE CACHE DYNAMIC the dynamic SQL statement cache is not completely cleared (some of the dynamic SQL statement elements are not reset). For example, looking at the dynamic SQL snapshot I see a certain SQL statement that has been executed a number of times and has read a (big) number of rows. Then I execute the "FLUSH PACKAGE CACHE DYNAMIC" command.
1
3387
by: neovantage | last post by:
Hey all, I am using a PHP script which creates headings at run time in a sense at page execution. I am stuck a with a very little problem which i am sure i will have the solution from experts. The problem is when it creates transparent PNG format image then and it pixel ate the image. e.g. If i am using a gradient in background then it vary in color range. Now when i used that php script it generates image successfully but it pixel ate...
0
8343
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8856
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5653
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1992
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.