Help Needed With Add and Remove Elements(JS)

Status
Not open for further replies.

Arpit15

Active Member
43
2011
3
470
hi,

i want two simple functions, one to add a input text field and the other to remove it dynamically.

code i am using:
Code:
var x=0;
function add() {
var dId = "div"+x;
x++;
 document.getElementById('extra').innerHTML += "<div id=\'"+dId+"\'>URL:<input type='text' name='url[]' value=''><a href=\"javascript:delete('"+dId+"')\">X</a></div><br />";
}
function delete(div) {
var d = document.getElementById('extra');
var d2 = document.getElementById(div);
d.removeChild(d2);
}

the problem is whenever i click the "X" in the generated field box, it opens in new window with some text saying "true", i guess it is an output for the function.
i don't want that output.

and i m using FF4 if it matters.
 
1 comment
Status
Not open for further replies.
Back
Top