User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 456,516 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,817 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1015 | Replies: 1
Reply
Join Date: Oct 2007
Location: Baltimore/DC
Posts: 33
Reputation: Tom Tolleson is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Tom Tolleson's Avatar
Tom Tolleson Tom Tolleson is offline Offline
Light Poster

function to create multiple objects

  #1  
Oct 4th, 2007
I have a page on which I want users to be able to create web objects on the same page with the push of a button. For example, to create a new draggable textfield object, a user would click on this button:

<form action="#">
    <input type="button" name="btn" id="btn" value="Make a Textfield" onclick="textfield(this);" />
	</form>

I'm not sure if that part is correct.

Below is the code for the function I came up with. However, it doesn't produce a new textfield. (Note the draggable class makes the object draggable - this part works if I create the textfield object manually).

function newtextfield() {
  newElement.type = "button";
        newElement.id = "button";
        newElement.name = "button";
        newElement.class = "draggable";

}

var newtextfield = next();

What would the function be for the button to produce textfields?

Thanks!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2006
Location: India
Posts: 7,012
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 25
Solved Threads: 368
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Lazy, Useless & Apathetic

Re: function to create multiple objects

  #2  
Oct 5th, 2007
Look into the createElement and appendChild functions of DOM to achieve your task.
I don't accept change. I don't deserve to live.

Happiness corrupts people.

Failing to value the lives of others cheapens your own.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 4:00 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC