I have some JavaScript code that only works when the alert statements are used/not hidden…
I hide or remark them out, and the code errors out with “‘options.length’ is null or not an object” — I am guessing it is line #27 where this is happening…
Here is the code snippet:
-
function editQuery(myForm) {
-
var f;
-
var x;
-
// Get the row filters that were used in the last query…
-
for (f = 1; f < 16; f++) {
-
var filter = element(“FilterList_” + f);
-
if (filter.selectedIndex > 0) {
-
var methodElement = element(“FilterMethod_” + f);
-
var methodIndex = methodElement.selectedIndex;
-
//alert("methodIndex: " + methodIndex);
-
var savedFilterMethodValue = methodElement.options[methodIndex].text;
-
var choicesElement = element(“FilterChoices_” + f);
-
var choicesIndex = choicesElement.selectedIndex;
-
//alert("choicesIndex: " + choicesIndex);
-
//alert("isNaN(choicesIndex): " + isNaN(choicesIndex));
-
if (isNaN(choicesIndex)) {
-
var savedFitlerValues = choicesElement.value;
-
}
-
else {
-
var savedFitlerValues = choicesElement.options[choicesIndex].text;
-
}
-
updateFilters(filter); // update the filters
-
// take the saved methods and values and then update the selections
-
// Since the object was updated, get the object again…
-
//alert("savedFilterMethodValue: " + savedFilterMethodValue);
-
var methodElement = element(“FilterMethod_” + f);
-
for (x = 0; x < methodElement.options.length; x++) {
-
//alert("x: " + x);
-
//alert("methodElement.options.text: " + methodElement.options.text);
-
if (methodElement.options.text == savedFilterMethodValue) {
-
methodElement.options.selected = true;
-
//alert(“Found match - out…”);
-
break;
-
}
-
}
-
// Since the object was updated, get the object again…
-
//alert("savedFitlerValues: " + savedFitlerValues);
-
var choicesElement = element(“FilterChoices_” + f);
-
for (x = 0; x < choicesElement.options.length; x++) {
-
//alert("x: " + x);
-
//alert("choicesElement.options.text: " + choicesElement.options.text);
-
if (choicesElement.options.text == savedFitlerValues) {
-
choicesElement.options.selected = true;
-
//alert(“Found match - out…”);
-
break;
-
}
-
}
-
// Only display next row if f = 2…
-
// If only one row was used, no reason display the next row…
-
if (f == 2) {
-
displayNextFilter(f - 1); // display it
-
}
-
}
-
}
-
}
I showed the alert on line 25 (all others are hidden) and it works fine, I hide it, it errors out…
Never had this happen…
Any ideas would be great — not much help in the JavaScript forums I belong to…
Thanks!
Dan