incubus0
08-13-2003, 08:58 AM
I was a bad boy and didn't build a break into a script. Now I have a user that needs to break out of an infinite loop that's already running. Do any of you know a way to do this?
Just in case, here is the code that's causing it.
There are rows of 6 fields each.
There are 2 scripts running.
1. Checks to make sure they entered either a number or the letters "NA". If not gives them an error message and sets the focus back to that field and selects it.
onBlur=ecovalues(this)
function ecovalues(field) {
var valid = "0123456789NA"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!" + "\n" + "Please enter numbers only or NA");
field.focus();
field.select();
}
}
2. While in field "ECO2" it checks the value entered on the above like field (in this case ECO1) and copies it to the field their on (ECO2), then selects the value of that field (ECO2).
onFocus="javascript:this.value=ECO1.value;this.select();"
The "infinite loop" was caused by the user first entering "na" (not "NA") in ECO1, then manually clicking in field ECO2. This caused the script to first check ECO1 and give an error message, then copy ECO1's value to ECO2, then check ECO2's value and give an error message.
I can fix the code easily enough, but I would like this user to be able to break out of it without loosing the values already entered on the page because they had about 100 lines typed in, and then went back to fill the ECOx fields when this happened, so they would have to re-enter everything if they reload the page.
I've tried opening Internet Options and disabling JavaScript through there, but it doesn't affect the page that's already loaded.
Any help would be appreciated.
Just in case, here is the code that's causing it.
There are rows of 6 fields each.
There are 2 scripts running.
1. Checks to make sure they entered either a number or the letters "NA". If not gives them an error message and sets the focus back to that field and selects it.
onBlur=ecovalues(this)
function ecovalues(field) {
var valid = "0123456789NA"
var ok = "yes";
var temp;
for (var i=0; i<field.value.length; i++) {
temp = "" + field.value.substring(i, i+1);
if (valid.indexOf(temp) == "-1") ok = "no";
}
if (ok == "no") {
alert("Invalid entry!" + "\n" + "Please enter numbers only or NA");
field.focus();
field.select();
}
}
2. While in field "ECO2" it checks the value entered on the above like field (in this case ECO1) and copies it to the field their on (ECO2), then selects the value of that field (ECO2).
onFocus="javascript:this.value=ECO1.value;this.select();"
The "infinite loop" was caused by the user first entering "na" (not "NA") in ECO1, then manually clicking in field ECO2. This caused the script to first check ECO1 and give an error message, then copy ECO1's value to ECO2, then check ECO2's value and give an error message.
I can fix the code easily enough, but I would like this user to be able to break out of it without loosing the values already entered on the page because they had about 100 lines typed in, and then went back to fill the ECOx fields when this happened, so they would have to re-enter everything if they reload the page.
I've tried opening Internet Options and disabling JavaScript through there, but it doesn't affect the page that's already loaded.
Any help would be appreciated.