The Code:
var i=0,j=0;
var t1= new Array();
function createtext(){
i++;
t1[i]=document.createElement('input');
t1[i].type='text';
t1[i].name='text'+i;
t1[i].value = "hello"+i;
t1[i].size = 10;
document.forms[0].appendChild(t1[i]);
var mybr=document.createElement("<br>");
document.appendChild(mybr);
}
The Form:
<form action="" method="get" name="f1">
<input name="b1" type="button" onClick="createtext()" value="+">
</form>
When Clicking the “+” button the textbox will generate downward not to the side of each textbox.. then each textbox has a “REMOVE” link in thier side.. when the “REMOVE” was click the textbox will remove.. pls help me.
------------------------------------------------
(+) <-imagine this is the button
[SAMPLETEXTBOX1] REMOVE <-imagine a textbox1 with remove link beside it
[SAMPLETEXTBOX2] REMOVE <-imagine a textbox2 with remove link beside it
[SAMPLETEXTBOX1] REMOVE <-imagine a textbox3 with remove link beside it
You should append to the
form, not thedocument, also usedocument.createElement("br")instead ofdocument.createElement("<br>").