[Javascript] javascript question. please help(dup)
BEKIM BACAJ
trojani2000 at hotmail.com
Thu Feb 27 19:01:59 CST 2003
I don't understand if you are having trouble assigning the form values to
the array, or accessing the arrays you need from the form splitting them,
but first you have to manage assingning the form values to the correspondent
arrays, than you can use them however you like.
Predefined Array length will become unusual if you change the length of the
form fields in later times.
The following will perhaps be a better way to get the field values of any
length inside the form:
**************************************************
<html>
<head>
</head>
<body>
<center>
<form name="farmform">
<input type="text" size="20" value="Cows">
<input type="text" size="4" value="77"><p>
<input type="text" size="20" value="Sheep">
<input type="text" size="4" value="120"><p>
<input type="text" size="20" value="Goats">
<input type="text" size="4" value="3"><p>
<input type="text" size="20" value="Pigs">
<input type="text" size="4" value="3"><p>
<input type="text" size="20" value="Horses">
<input type="text" size="4" value="3"><p>
<input type="text" size="20" value="Mules">
<input type="text" size="4" value="17"><p>
<input type="text" size="20" value="Chickens">
<input type="text" size="4" value="43"><p>
<input type="text" size="20" value="Ducks">
<input type="text" size="4" value="120"><p>
<input type="text" size="20" value="Raptors">
<input type="text" size="4" value="7"><p>
</form>
<Button onClick="farmcount()">GO</button>
</center>
<SCRIPT LANGUAGE=JavaScript>
var s=farmform.length;//if you put the 'GO' button inside the Form, write
s=farmform.length-1
var fn=new Array();
function farmcount(){
for(i=0; i<s; i++) {
fn[i]=' '+farmform.elements[i].value;
}
document.write(document.body.innerHTML +"<b><CENTER>"+fn+".</CENTER></b>");
}
</SCRIPT>
</body>
</html>
Any further questions...
-Post at the same forum!
Cheers!
_________________________________________________________________
The new MSN 8: smart spam protection and 2 months FREE*
http://join.msn.com/?page=features/junkmail
More information about the Javascript
mailing list