In article <t0***************@newsfe1-win.ntli.net>,
"sh0t2bts" <sh******@hotmail.com> wrote:
In my java script I want to loop through and pick up the values of each
field so I was looking at replacing the number with a variable
sort of like this
Count = 0
While Count < 10
if DocumentName.Con_Hours" + Count + ".value != DocumentName.Old_Con_Hours"
+ Count + ".value
I do not recognize this as valid javascript syntax.
I suggest that you invest in a Javascript book. The best book for
experienced programmers is: javascript
: The Definitive Guide by David
Flanagan.
Here is a possible solution:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Saving stats</title>
<base href="http://spaceplace.jpl.nasa.gov/en/">
<script type="text/javascript">
/*
Con_Hours0 Old_Con_Hours0
Con_Hours1 Old_Con_Hours1
Con_Hours2 Old_Con_Hours2
Con_Hours3 Old_Con_Hours3
etc
etc
In my java script I want to loop through and pick up the values of each
field so I was looking at replacing the number with a variable
sort of like this
*/
// array is a good place to store a numeric list
var old_con_hours = [ ]
function validate(x)
{
// When true, we found a change so return false which means the form
will
// be submitted.
// When false, we found a change so return false which means the form
will
// not be submitted.
var proceed = true;
for (var i = 0;;i++)
{
// Check if the text field exists.
if (x.elements["Con_hours"+i])
{
if (x.elements["Con_hours"+i].value != old_con_hours[i] )
{
old_con_hours[i] = x.elements["Con_hours"+i].value;
alert("Con_hours number " + i + " has changed.");
proceed = false;
}
}
else
{
// since the text fields doesn't exist, we have reached the end
break;
}
}
return proceed;
}
</script>
</head>
<body >
<P>Sum up a bunch of text fields.</p>
<form name="myForm"
action="http://www.natAValidWebAddress.com"
method="POST"
onsubmit="return validate(document.forms['myForm']);">
<p>Count Hours:
<br><br>
0: <input type="text" name="Con_hours0" size="40">
<br>
1: <input type="text" name="Con_hours1" size="40">
<br>
2: <input type="text" name="Con_hours2" size="40"></p>
<br>
<br>
<input type="submit" value="Submit address information">
</form>
</p>
</body>
</html>