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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i manage this?

Status
Not open for further replies.

Kijori

Technical User
Jan 22, 2002
67
SG
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=&quot;Javascript&quot;>
function addTF(x,y) {
var t = &quot;<input type='button' value='Insert Textfield' onClick='addTF(2,0);'><br>&quot; +
&quot;<div id='test2'></div>&quot;;
if (y == 1)
test.innerHTML = t;
else
test2.innerHTML = t;

}
</script>
</head>
<body>
Testing...<input type=&quot;button&quot; value=&quot;Insert Textfield&quot; onClick=&quot;addTF(1,1);&quot;><br>
<div id=&quot;test&quot;></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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top