Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

creating text boxes dynamically 1

Status
Not open for further replies.

coderwasp

Programmer
Jan 10, 2007
24
US
I have a select box with values 1-20. What I'd like to do is onChange, write a set of textboxes corresponding to the value in the select box. For instance, if the user selects 6, then 6 text boxes would appear on the page.

It could be something like:

<input name="text1" type="text" size="20">
<input name="text2" type="text" size="20">
.
.
.
.
 
Something like this:

HTML:
Code:
<select blablahblkahblaj  onchange="drawTextboxes(this.value)">
<div id="textBoxArea"></div>

Javascript:
Code:
function drawTextboxes(boxNo) {
   var divContents = "";
   for (a = 0; a <= boxNo; a++) {
      divContents += '<input name="text' + a + '" type="text" size="20">'
   }
   document.getElementById("textBoxArea").innerHTML = divContents;
}

This is barebones, however ***Tested.



[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top