Jump to content

Js Code Works In Firefox But Not In Ie


mjsulliv
 Share

Recommended Posts

arrayValue = currentParentDataArray_ary[0][inputSourceColumn]; // get first array element

The js code shown above works fine in Firefox but causes the following error in IE.

Message: '0' is null or not an objectLine: 202Char: 3Code: 0

Any thoughts would be appreciated.

Link to comment
Share on other sites

The program pulls the data for the “top level array” from an HTML table:

function loadTableDataIntoParentDataArray(){  var i, j, targetRow;  var numberOfRows = inputSourceTable_tbl.rows.length;  var testRow = inputSourceTable_tbl.rows[0];  var numberOfColumns = testRow.cells.length;  for (i = 0; i < numberOfRows; ++i) {	targetRow = inputSourceTable_tbl.rows[i];	var rowArray = new Array();	for (j = 0; j < numberOfColumns; ++j) {	  var targetCell = targetRow.cells[j];	  var cellText = targetCell.innerHTML;	  rowArray[j] = cellText;	}	topLevelDataArray_ary[i] = rowArray;  }  protocolDataArray_ary = []; // clear array  protocolDataArray_ary = topLevelDataArray_ary.slice(); // copy array}

This “top level array” goes through several reducing copies as such:

function BuildSubArray(ParentArray_ary, selectedColumn, targetValue, ChildArray_ary){  //  alert("IN: BuildSubArray(...)");  var childArrayIndex = 0;  for (var x in ParentArray_ary)  {	var testValue = ParentArray_ary[x][selectedColumn];	if(targetValue == testValue){  // is this a row with the targetValue in the selected column? If so copy to child array	  ChildArray_ary[childArrayIndex] = ParentArray_ary[x]; // store row with match	  childArrayIndex++;	}  }}

The function where the error occurs is:

function BuildVectorUniqueValues(currentParentDataArray_ary, inputSourceColumn){  //  alert("IN:BuildVectorUniqueValues(...)");  selectionList_ary = [];  var arrayValue;  var listValue;  var inputArrayLen = currentParentDataArray_ary.length;  arrayValue = currentParentDataArray_ary[0][inputSourceColumn]; // get first array element  selectionList_ary[0] = arrayValue; // copy to result  for(var i=1;i<inputArrayLen;i++)  {	arrayValue = currentParentDataArray_ary[i][inputSourceColumn];	var outputArrayLen = selectionList_ary.length;	for(var j=0;j<outputArrayLen;j++)	{	  listValue = selectionList_ary[j];	  if(arrayValue == listValue){		break;	  }	  if(j == (outputArrayLen - 1)){		selectionList_ary[outputArrayLen] = arrayValue; // tack value on to end of output	  }	}  }}

Any Insights?Thanks --- Mike

Link to comment
Share on other sites

Sorry. I don't see the code that connects all these functions. None of them seems to call the other. So I don't know if I am seeing currentParentDataArray_ary being created or not. Specifically, we need to see the line of code that calls BuildVectorUniqueValues(), and we need to see the code that constructs the array object that gets passed to BuildVectorUniqueValues(). You have a lot of arrays in these functions and I don't want to just guess which one it is.I will say I wonder about these lines:protocolDataArray_ary = []; // clear arrayprotocolDataArray_ary = topLevelDataArray_ary.slice(); // copy arrayBut they probably don't cause the error.

Link to comment
Share on other sites

Sorry. I don't see the code that connects all these functions. None of them seems to call the other. So I don't know if I am seeing currentParentDataArray_ary being created or not. Specifically, we need to see the line of code that calls BuildVectorUniqueValues(), and we need to see the code that constructs the array object that gets passed to BuildVectorUniqueValues(). You have a lot of arrays in these functions and I don't want to just guess which one it is.I will say I wonder about these lines:protocolDataArray_ary = []; // clear arrayprotocolDataArray_ary = topLevelDataArray_ary.slice(); // copy arrayBut they probably don't cause the error.
yes there are a lot of arrays and I'm trying to avoid posting the whole JS file but I can If that's what's wanted. I'll try to work on a pared down program that still has the error.
Link to comment
Share on other sites

The correct way to set up an option is this:

<option value="myValue">some text</option>

And I think we've been assuming that structure all along. If your option tag does not have a value attribute, then you may have a problem. Some browsers will be nice and return the display text in the value property, but as you may have seen, that behavior is inconsistent. To get what you want, always use the value attribute.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...