mjsulliv Posted March 9, 2010 Report Share Posted March 9, 2010 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 More sharing options...
jeffman Posted March 9, 2010 Report Share Posted March 9, 2010 Thought #1: you could have saved yourself some time by posting more code. Ideally, you can show us how the array is constructed. Link to comment Share on other sites More sharing options...
mjsulliv Posted March 10, 2010 Author Report Share Posted March 10, 2010 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 More sharing options...
jeffman Posted March 10, 2010 Report Share Posted March 10, 2010 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 More sharing options...
mjsulliv Posted March 10, 2010 Author Report Share Posted March 10, 2010 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 More sharing options...
mjsulliv Posted March 16, 2010 Author Report Share Posted March 16, 2010 Found the solution. Firefox was happy w/ var selectValue = select1.options[select1.selectedIndex].value; IE needed: var selectValue = select1.options[select1.selectedIndex].innerHTML; Link to comment Share on other sites More sharing options...
ShadowMage Posted March 16, 2010 Report Share Posted March 16, 2010 Your first one: var selectValue = select1.options[select1.selectedIndex].value; should work in both FF and IE. In fact I use it and it does work in both. Link to comment Share on other sites More sharing options...
jeffman Posted March 16, 2010 Report Share Posted March 16, 2010 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now