View Full Version : When i click on a button once, a textbox will be created
sumanreddy
01-28-2005, 03:58 AM
hai,
i want to do something like this,
When i click on a button once, a textbox will be created.
I click again, another textbox will be created.
coothead
01-28-2005, 06:04 AM
Hi there sumanreddy,
and a warm welcome to these forums :)
here is a simple example of element creation...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>create textareas</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<script type="text/javascript">
//<![CDATA[
var count=0; /*count is used to limit the number of boxes
and can be removed if not required*/
function createThings() {
var container=document.createElement("div");
container.setAttribute("width",350);
var textbox=document.createElement("textarea");
textbox.setAttribute("cols",30);
textbox.setAttribute("rows",10);
container.appendChild(textbox)
if(count<3) {
document.getElementById("theForm").appendChild(container);
count++;
}
}
//]]>
</script>
</head>
<body>
<form id="theForm" action="#">
<div><input type="button" value="create" onclick="createThings()"/></div>
</form>
</body>
</html>
sumanreddy
01-29-2005, 04:13 AM
Thanks
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.