Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

59 users online



Creating input boxes on the fly

Creating input boxes on the fly

Currently viewing this thread: 1 (0 members and 1 guests)


alsaffar

alsaffar

Neverside Newbie
Status: Offline!

Creating input boxes on the fly

Hi there,

How can I have a form with (drop down menu of values from 1 to 20) so if I select for example 5, then 5 input boxes will be created on the fly (each one under the other) of the same name but different indexes e.g. TextBox[1] TextBox[2] etc...

I hope I was clear Smile

Thanx alot in advance.

Ynhockey

Ynhockey

Neverside Newbie
Status: Offline!

I think it's like:

if (document.FORMNAME.SELECTBOXNAME.value == SELECTEDVALUE)
{
document.write("<input type='text'>");
}

Something like that... but maybe it won't work. I think it's better to pre-load the boxes and display them instead:

if (document.FORMNAME.SELECTBOXNAME.value == SELECTEDVALUE)
{
document.FORMNAME.INPUTNAME.style.display = 'block';
}

___________________

Learn HTML

riah

riah

now with more lambda
Status: Offline!

Function that creates input boxes:

Code:


// n = number of inout boxes
// myForm is the form element to append the boxes to
function createInputs(n, myForm){
for(var i=0; i<n; i++){
myForm.appendChild(document.createElement('input'));
}
}

___________________

http://codetch.com/skin/sig.png

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0066 seconds.