Melannie
September 21st, 2005, 03:56 PM
Hi!
I got this script: http://javascript.internet.com/forms/adding-html-controls.html
And i want to do a multiple input with this value (name, lastname, town)
I have a problem i don't know how to kept the display of my value.
someone can help me ?
Thanks!
Mel.
My code:
<html>
<head>
<script type="text/javascript">
<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Husay :: http://www.communitxt.net */
var arrInput = new Array(0);
var arrInputValue = new Array(0);
function addInput() {
//arrInput.push(createInput(arrInput.length));
arrInput.push(arrInput.length);
//arrInputValue.push(arrInputValue.length);
arrInputValue.push("");
display();
}
function display() {
document.getElementById('parah').innerHTML="";
for (intI=0;intI<arrInput.length;intI++) {
document.getElementById('parah').innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
}
}
function saveValue(intId,strValue) {
arrInputValue[intId]=strValue;
}
function createInput(id,value) {
return "<tr><td><input type='text' name='name"+intI+"' onChange='javascript:saveValue1("+intI+",this.value)' value='"+ value +"'></td><td><input type='text' name='lastname"+intI+"' onChange='javascript:saveValue2("+intI+",this.value)' value='"+ value +"'></td><td><input type='text' name='town"+intI+"' onChange='javascript:saveValue3("+intI+",this.value)' value='"+ value +"'></td></tr>";
}
function deleteInput() {
if (arrInput.length > 0) {
arrInput.pop();
arrInputValue.pop();
}
display();
}
// End -->
</script>
</head>
<body>
<form method="post" action="##" enctype="multipart/form-data">
<table border="1">
<tr>
<td>name</td><td>lastname</td><td>town</td>
</tr>
<tbody id="parah"></tbody>
</table>
<input type="submit" value="GO"><br>
</form>
<a href="javascript:addInput()">Add row</a><br>
</body>
</html>
I got this script: http://javascript.internet.com/forms/adding-html-controls.html
And i want to do a multiple input with this value (name, lastname, town)
I have a problem i don't know how to kept the display of my value.
someone can help me ?
Thanks!
Mel.
My code:
<html>
<head>
<script type="text/javascript">
<!-- Begin
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Husay :: http://www.communitxt.net */
var arrInput = new Array(0);
var arrInputValue = new Array(0);
function addInput() {
//arrInput.push(createInput(arrInput.length));
arrInput.push(arrInput.length);
//arrInputValue.push(arrInputValue.length);
arrInputValue.push("");
display();
}
function display() {
document.getElementById('parah').innerHTML="";
for (intI=0;intI<arrInput.length;intI++) {
document.getElementById('parah').innerHTML+=createInput(arrInput[intI], arrInputValue[intI]);
}
}
function saveValue(intId,strValue) {
arrInputValue[intId]=strValue;
}
function createInput(id,value) {
return "<tr><td><input type='text' name='name"+intI+"' onChange='javascript:saveValue1("+intI+",this.value)' value='"+ value +"'></td><td><input type='text' name='lastname"+intI+"' onChange='javascript:saveValue2("+intI+",this.value)' value='"+ value +"'></td><td><input type='text' name='town"+intI+"' onChange='javascript:saveValue3("+intI+",this.value)' value='"+ value +"'></td></tr>";
}
function deleteInput() {
if (arrInput.length > 0) {
arrInput.pop();
arrInputValue.pop();
}
display();
}
// End -->
</script>
</head>
<body>
<form method="post" action="##" enctype="multipart/form-data">
<table border="1">
<tr>
<td>name</td><td>lastname</td><td>town</td>
</tr>
<tbody id="parah"></tbody>
</table>
<input type="submit" value="GO"><br>
</form>
<a href="javascript:addInput()">Add row</a><br>
</body>
</html>