ptpovo
asked on
Stack overflow in function ( )
I need a definition of "stack overflow". In general, what are the possible causes?
************************** ********** ********** ********** **********
I have an array of objects, each contains a string value.
itemList = new makeArray(8);
itemList[1] = new itemType("green1");
itemList[2] = new itemType("green2");
itemList[3] = new itemType("green3");
itemList[4] = new itemType("red1");
itemList[5] = new itemType("red2");
itemList[6] = new itemType("blue1");
itemList[7] = new itemType("blue2");
itemList[8] = new itemType("blue3");
There are 3 sub classes or sub qualities: green, red, & blue. For the purposes of creating an array, this would not seem to matter much as they are only string values and the user chooses one via radio button. Where I think I may be running into a problem though, is in the way I wish to present the choices to the user. The following demonstrates how I am accessing the array through three separate functions:
function createGreenRadio(hName, itemList) {
var tStr = "";
for(var i=1; i<=3; i++) {
tStr += "<INPUT NAME=\"" + hName + "\" "
+ "TYPE=radio VALUE=\"" + itemList[i].item + "\">"
+ itemList[i].item;
}
return tStr;
}
In the next two, the only difference is the name of the function and the "for" statement:
for(var i=4; i<=5; i++) /* and */ for(var i=6; i<=8; i++)
The body of the document contains 3 correspnding function calls from within a table:
document.write("<TD>" + createGreenRadio("itemMake ", itemList) + "<BR></TD>");
In the next 2, the only difference is the function name:
createRedRadio /* and */ createBlueRadio
The output looks fine. Is there something inherantly wrong with accessing an array in this manner?
************************** ********** ********** ********** ********** **
**************************
I have an array of objects, each contains a string value.
itemList = new makeArray(8);
itemList[1] = new itemType("green1");
itemList[2] = new itemType("green2");
itemList[3] = new itemType("green3");
itemList[4] = new itemType("red1");
itemList[5] = new itemType("red2");
itemList[6] = new itemType("blue1");
itemList[7] = new itemType("blue2");
itemList[8] = new itemType("blue3");
There are 3 sub classes or sub qualities: green, red, & blue. For the purposes of creating an array, this would not seem to matter much as they are only string values and the user chooses one via radio button. Where I think I may be running into a problem though, is in the way I wish to present the choices to the user. The following demonstrates how I am accessing the array through three separate functions:
function createGreenRadio(hName, itemList) {
var tStr = "";
for(var i=1; i<=3; i++) {
tStr += "<INPUT NAME=\"" + hName + "\" "
+ "TYPE=radio VALUE=\"" + itemList[i].item + "\">"
+ itemList[i].item;
}
return tStr;
}
In the next two, the only difference is the name of the function and the "for" statement:
for(var i=4; i<=5; i++) /* and */ for(var i=6; i<=8; i++)
The body of the document contains 3 correspnding function calls from within a table:
document.write("<TD>" + createGreenRadio("itemMake
In the next 2, the only difference is the function name:
createRedRadio /* and */ createBlueRadio
The output looks fine. Is there something inherantly wrong with accessing an array in this manner?
**************************
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I see nothing inherently wrong with your code. Under what circumstances do you get a stack overflow? What browser, what version and what operating system?
ASKER