0

Using jQuery 1.9.1 & IE8, but the page also needs to work in IE7. In code before the part that is causing the issue, I read some data in & build an array that is a SELECT statement. In the section of code where I have an issue, I am doing the following:

var found = $.map( mySelArr, function(val) {
   return val.mySelID === zSelID ? val.mySelStatement: null;
   });

I then reference it:

var selStmt = found[0];  

(there will be only 1 returned, and I know it will be in the array).

In IE7, I saw that it is throwing an exception inside jquery.js. When I step through debug on it, I see that the found length is zero (in IE7). If I change the mode to IE8, everything works fine. But in IE7, nothing gets put into the found variable.

What am I doing wrong to not be able to get this array value out in IE7? Would appreciate any thoughts.

EDIT

mySelArr is an array of Select statements, similar to:

1,<select name='mySelID_1' id='plist' ><option selected='selected' disabled='disabled' value='0'>Select Action</option><option value="1">This one</option><option value="2">That one</option></select>

and so on.

EDIT 2

I may have stumbled on the issue.

The array that held the select statements was being populated correctly in IE8, but not in IE7.

I actually had 2 arrays, one being just a number, and the other being that same number + the Select statement. The array that had the index & select statement was built using:

arr1.push({ fld1:data1, fld2:selstmt})

The one with just numbers was built using:

arr2.push(arrndx)

The arr2 was the outer FOR, the arr1 was the inner FOR. I had been referring to the number index by using:

var z = arr2[x][0];

to get the number & then using that to loop thru arr1 to get everything matching it & building the Select statement. What I discovered was that IE7 was returning undefined in the line of code above, while IE8 was returning the number (Firefox also).

I changed 2 lines of code to fix the issue:

FROM   arr2.push(arrndx) 
TO     arr2.push( {arrindex: arrndx} );

and

FROM   arr2[x][0]
TO     arr2[x].arrindex

and it works in both IE7 & IE8. IE7 didn't have a problem creating that array, or reading it - it just wasn't valid data in it because of how I attempted to reference the fields in it.

I'm not exactly sure why IE7 had a problem with it & IE8 didn't, but.... Also, the fix didn't appear to break anything else.

4

0 回答 0