469,327 Members | 1,226 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

Dynamically Create Input Box on Client Side

I'm trying to find a way to create input boxes dynamically on the
client side but everything that I've come across works with IE, but not
FireFox.

On my web page, I have the following input boxes:
txtAddress1, txtCity1,txtState1, txtZip1

What I'd like to do is to have a button that says "Add Another
Location". When the user clicks on the button, then txtAddress2,
txtCity2, txtState2, and txtZip2 are created below the first location
input boxes. The user should be able to enter an unlimited number of
locations (within reason) to the web page.

Is this possible with JavaScript?

Thanks,
CR Junk

Dec 8 '05 #1
2 8232

crjunk wrote:
I'm trying to find a way to create input boxes dynamically on the
client side but everything that I've come across works with IE, but not
FireFox.

On my web page, I have the following input boxes:
txtAddress1, txtCity1,txtState1, txtZip1

What I'd like to do is to have a button that says "Add Another
Location". When the user clicks on the button, then txtAddress2,
txtCity2, txtState2, and txtZip2 are created below the first location
input boxes. The user should be able to enter an unlimited number of
locations (within reason) to the web page.

Is this possible with JavaScript?


Yes.

Mainly, there are two things you should know how to use. You should go
look up the following:

document.createElement()
appendChild()

For example, I'll create one html input element with the name
txtAddress2 for you:

var input = document.createElement("input");
input.type = "text";
input.name = "txtAddress2";

var elem = document.getElementById("container");
elem.appendChild(input);

Dec 8 '05 #2
Thanks for your help. After searching for document.creatElement, I came
across
http://www.design-ireland.net/index..../design-20.php

This helped me figure out how to create different elements.

CR Junk

Dec 9 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by crjunk | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.