PDA

View Full Version : Strange infinite loop; involves combobox


antago
01-05-2008, 03:44 PM
So I have this test to load information from an account, then it searches through a combobox to see which item matches the information in the account and then it stops on that item. In other words, it loads the information stored in the account for that combobox to select that item in the combobox.

There is an item called "1.8" in the combobox and data "1.8" in this.pheight. The item "pheight.pheight" is the combobox. "this.pheight" refers to "result2_lv". This is fine, because I have a "year.year" combobox which is an integer result and it uses "this.year" variable for the account information, and it indeed does work. It finds and stops on the selected item in the combobox matching the year.

My question is, is there something really strange about comparing "1.8" to "1.8" that makes this not work?? Someone please help.

if (this.pheight==0) {
pheight.pheight.selectedIndex = 0;
} else {
while (pheight.pheight.selectedItem.label != this.pheight) {
pheight.pheight.selectedIndex ++;
}
}

MIXPOSURE
01-05-2008, 05:38 PM
Hi,

My greenhorn noggin is thinking that it might be a datatype issue and I would change the "1.8"'s to "18"'s as a test.

Sorry if I got your hopes up for a more competent answer. Good luck.

antago
01-07-2008, 05:54 AM
Thanks, but that really won't help me as that can create an entirely new number altogether. Really, there is no reason why I can't compare 1.8 to 1.8 and have it be equal. I cast both of them as Number() as well.
Somebody, please help. This seems very strange

antago
01-07-2008, 06:11 AM
I fixed it by putting ".toString()" at the end of all the variables in the conditional statement.
For instance, "while (pheight.pheight.selectedItem.label.toString() != this.pheight.toString())"
:-)