...

View Full Version : create textbon on button click



sumanreddy
01-28-2005, 11:29 AM
hai,

When i click on a button once, a textbox should be created.
I click again, another textbox should be created.

how to do this

Kor
01-28-2005, 12:23 PM
welcome to the Forum

Try this DOM example:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script language="JavaScript" type="text/JavaScript">
var k=1;
function newT(){
var oName ='mytextbox'+k;//here's the name of the first texbox: mytextbox1
//The folowing will be incremented as mytextbox2, mytextbox3, mytextbox4 and so on
var root = document.getElementById('cont');
var oInp = document.createElement('input');
var oBr = document.createElement('br');
oInp.setAttribute('type','text');
oInp.setAttribute('name',oName);
root.appendChild(oInp);
root.appendChild(oBr);
k++;
}
</script>
</head>
<body>
<input type="button" value="Create new textbox" onclick="newT()"><br>
<br>
<div id="cont"></div>
</body>
</html>

sumanreddy
01-29-2005, 10:22 AM
Thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum