Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Capture the count of an array 1

Status
Not open for further replies.

tomhughes

Vendor
Aug 8, 2001
233
US

Does anyone know how to capture the count of an array when the array value matches the value of a text box. I have tried looping through the array with a "for" loop, and
using an "if" statement and a break command to get out of the loop, but I cannot figure out how to get the count value of the array. Here are some of the actionscripts
I have used. The "out" is a Dynamic text box. txtValue is the value of the data to match in the array. THe only way I could get the data I want is to use a long drawn out group of "Else If" statements. The Array data I used was text, not numbers.

*************************

var sum = 0;
for (i=0; i<KeyArray.length; i++) {
sum++;
if (KeyArray=txtValue) {
break;
}
out = "The Sum Value is "+sum;
}


**************************

for (i=0; i<KeyArray.length; i++) {
if (KeyArray=txtValue) {
break;
}
out = KeyArray;
}


**************************
var sum = 0;
for (i=0; i<KeyArray.length; i++) {
x = KeyArray;
trace(x);
y = txtValue;
trace(y);
sum = Number(sum+1);
trace(sum);
if (x == y) {
break;
}
out = sum;
}


*************************

do {
i = i+1;
if (KeyArray == txtValue) {
break;
}
out = KeyArray;
} while (i<23);

****************************
 
input text box txtValue and button btn

KeyArray = ["one", "two"];
btn.onRelease = function() {
for (i=0; i<KeyArray.length; i++) {
if (KeyArray==txtValue.text) {
trace("match");
}
}
};
 
Thanks Bill - I have been working on this for days. I appreciate your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top