Click to See Complete Forum and Search --> : is it possible to make more textfields appear


damon2003
12-04-2003, 07:11 AM
Hi,
is it possible to make textfields appear on a page based on what the user inputs into a textfield?
thanks

clairec666
12-04-2003, 07:15 AM
Yes - totally possible. For example, you have a form with a text input, and you want the number inputted into this field to be the number of textfields on the page.

Eg.
<script type="text/javascript">
function checknumber() {
boxnumber = document.all.form1.fieldnumber.value;
for(i=0; i<boxnumber; i++) {
document.write("<input type='text' name='text"+i+"'>");
}
}
</script>

Gollum
12-04-2003, 07:19 AM
Sure it is :D - that's what DHTML is all about. And there are countless ways to go about it.
Here's an example:

<input type=text onchange="var n = this.cloneNode(); n.value = ''; this.parentNode.appendChild(n);">

damon2003
12-08-2003, 06:02 AM
thanks,
is it possible to delete elements from a page?

fredmv
12-08-2003, 06:08 AM
Sure is:document.body.removeChild(foo);Where foo is a reference to the HTMLElement object you want to remove.