M
Mark Hannon
I am trying to wrap my brain around storing form elements inside
variables & arrays before I move on to a more complicated project. I
created this simple example to experiment and as far as I can tell, it
should work but it doesn't. Can someone tell me where I went wrong?
<html><head>
<title>Form Test</title>
<script language="JavaScript>
<!--
function copy(){
var firstField = new Array();
var secondField = new Array();
for(j=0; j<=4; j++){
firstField[j] = document.myForm.numText;
}
for(i=0; i<=4; i++){
secondField = document.myForm.copyText;
}
firstField[0].value = "mark";
firstField[1].value = "hannon";
firstField[2].value = "anne";
firstField[3].value = "mulligan";
for(k=0; k<=4; k++){
secondField[k].value = firstField[k].value;
document.myForm.iValue.value = k;
}
}
// -->
</script>
</head>
<body bgcolor="#FFFFFF">
<form id="myForm" name="myForm" action="" method="POST"
enctype="text/plain">
value of i: <input name="copyBut" type="button" value="Copy"
onClick="copy()">
</form>
</body>
</html>
variables & arrays before I move on to a more complicated project. I
created this simple example to experiment and as far as I can tell, it
should work but it doesn't. Can someone tell me where I went wrong?
<html><head>
<title>Form Test</title>
<script language="JavaScript>
<!--
function copy(){
var firstField = new Array();
var secondField = new Array();
for(j=0; j<=4; j++){
firstField[j] = document.myForm.numText;
}
for(i=0; i<=4; i++){
secondField = document.myForm.copyText;
}
firstField[0].value = "mark";
firstField[1].value = "hannon";
firstField[2].value = "anne";
firstField[3].value = "mulligan";
for(k=0; k<=4; k++){
secondField[k].value = firstField[k].value;
document.myForm.iValue.value = k;
}
}
// -->
</script>
</head>
<body bgcolor="#FFFFFF">
<form id="myForm" name="myForm" action="" method="POST"
enctype="text/plain">
<input name="iValue" type="text" value="" size="2" maxlength="2" ><br><br>
value of i: <input name="copyBut" type="button" value="Copy"
onClick="copy()">
</form>
</body>
</html>