View Single Post
  #7 (permalink)  
Old 04-11-2008, 01:25 PM
chili5's Avatar   
chili5 chili5 is offline
Code Warrior
 
Join Date: Mar 2008
Age: 15
Posts: 3,450
Credits: 312
Rep Power: 31
chili5 is a name known to allchili5 is a name known to allchili5 is a name known to allchili5 is a name known to allchili5 is a name known to allchili5 is a name known to all
Default Re: Javascript to Add a Text Input field

I believe that this should work for you.

HTML Code:
<html>
<head>
<title></title>
<script language="javascript">
fields = 0;
function addInput() {
if (fields != 1) {
document.getElementById('text').innerHTML += "<input type='button' onclick='reset()' value='Reset fields' />";
fields += 1;
document.form.add.disabled=true;
} else {
}
}

function reset() {
document.form.title.value = "";
document.form.name.value = "";
document.copy.name.value = "";
}
</script>
</head>
<body>
<form name="form" action="form.php" method="post">
Title: <input type="text" name="title" />
<br />Name: <input type="text" name="name" />
<br />Copy: <input type="text" name="copy" />
<br /><input type="button" onclick="addInput()" name="add" value="Add erase button" />


<div id="text">

</div>
</form>
</body>
</html>
Hopefully that's what you wanted.
Reply With Quote