0

I saw this and this topics, but not solved my problem.

Here is my code what is working fine in Chrome and Firefox, but in Internet Explorer not working (tested only in IE8):

var myjson = {'dat':[
    {'myval':'100','price':'1300'},
    {'myval':'100','price':'950'},
    {'myval':'20','price':'100'},
    {'myval':'0','price':'1000'},
    {'myval':'100','price':'750'},
]};
var myotherval = 0;
for (var i = 0; i < myjson.dat.length; i++) {
    if ( (myjson.dat[i].myval == 0 || myjson.dat[i].myval == 0) && myotherval == 0 ) {
        // do something
    }
}

The Internet Explorer say is NULL, or not an object. Every variable has value every time. Several times they are 0.

Anybody has any idea? Where can I find the error?

Community
  • 1
  • 1
netdjw
  • 5,419
  • 21
  • 88
  • 162

1 Answers1

0

Make sure that

myjson.dat[i].myval

is an integer. Use http://www.w3schools.com/jsref/jsref_parseint.asp

parseInt(myjson.dat[i].myval) == 0
Mihai
  • 2,740
  • 31
  • 45