All,
Just incase anyone is interested this is the final code. I needed to change
the input id in the html below from id="idBoxOne" to id="id_BoxOne".
This returns an array of any form tag that has an id that starts with id_ .
The only real change made to Lee's code was insted of passing the name to
the function using listIDs(document.forms['FormXX'])", I got the name of the
first form by using document.forms[0].name, so the onLoad event would now be
onLoad=listIDs().
Thanks for the starting point Lee.
CES
function listIDs(){
var a = document.forms[0].name; // Retrevies the name of the first form
on the page
var f = document.forms[a];
var nArray = new Array(); //Initializes the array
var z = 0; //Sets the array index number
for(var i = 0;i < f.elements.length;i++){ //Loops thru all ellements in
the form
var x = f.elements[i].id; // Assigns the value of the forms element to
var
var y = x.split("_"); //Determines if the Element is to be tracked, all
tracked elements have the "id_"
if(y[0] == "id"){ //If the left portion of the is is id then it adds
right item to array
nArray[z] = y[1];
z++ // increments by one
}
}
return nArray;
}
CES
"Lee" <RE**************@cox.net> wrote in message
news:bm********@drn.newsguy.com...
CES said:
All,
Is their a way of iterating thru each tag within a form and returning the
value given in the id property, by that I mean the below html would
returnthe values idBoxOne, idBoxTwo, idBoxThree from the FormXX form.
<form name="FormXX" method="post" action="default.htm">
<input id="idBoxOne" name="bxOne" type="text">
<input id="idBoxTwo" name="bxTwo" type="text">
<input id="idBoxThree" name="bxThree" type="text">
</form>
Up to this point I've only used JavaScript to change CSS properties,
innerHTML and outerHTML so I'm rather new to the game.
Any help is always appreciated.
<html>
<head>
<script type="text/javascript">
function listIDs(f){
var msg="";
for(var i=0;i<f.elements.length;i++){
msg+=i+": id: "+f.elements[i].id
+" name: "+f.elements[i].name
+" type: "+f.elements[i].type
+"\n";
}
alert(msg);
}
</script>
</head>
<body onload="listIDs(document.forms['FormXX'])">
<form name="FormXX" method="post" action="default.htm">
<input id="idBoxOne" name="bxOne" type="text">
<input id="idBoxTwo" name="bxTwo" type="text">
<input id="idBoxThree" name="bxThree" type="text">
</form>
</body>
</html>