By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,462 Members | 1,057 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,462 IT Pros & Developers. It's quick & easy.

Dynamically Create Input Box on Client Side

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a

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

P: n/a
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.