i need to be able to dynamically add a new textfield whenever a button is pressed. my failed code is as below...
<html>
<head>
<title>Testing</title>
<script language="Javascript">
function addTF(x,y) {
var t = "<input type='button' value='Insert Textfield' onClick='addTF(2,0);'><br>" +
"<div id='test2'></div>";
if (y == 1)
test.innerHTML = t;
else
test2.innerHTML = t;
}
</script>
</head>
<body>
Testing...<input type="button" value="Insert Textfield" onClick="addTF(1,1);"><br>
<div id="test"></div><br>
</body>
</html>
when the Insert Textfield button is pressed initially, a new textfield with its corresponding button is created. thus, i have two textfields and buttons. i know how to create the third pair.
what i want to know is... how do you increment the x in addTF(x,y) whenever the latest button is pressed? the x incremental will correspond to the test(x) id.
thanks in advance.
<html>
<head>
<title>Testing</title>
<script language="Javascript">
function addTF(x,y) {
var t = "<input type='button' value='Insert Textfield' onClick='addTF(2,0);'><br>" +
"<div id='test2'></div>";
if (y == 1)
test.innerHTML = t;
else
test2.innerHTML = t;
}
</script>
</head>
<body>
Testing...<input type="button" value="Insert Textfield" onClick="addTF(1,1);"><br>
<div id="test"></div><br>
</body>
</html>
when the Insert Textfield button is pressed initially, a new textfield with its corresponding button is created. thus, i have two textfields and buttons. i know how to create the third pair.
what i want to know is... how do you increment the x in addTF(x,y) whenever the latest button is pressed? the x incremental will correspond to the test(x) id.
thanks in advance.