0

I am having to support IE7 and the following line is throwing an error in the console:

document.getElementById("statusFilter").setValue("0");

The error I am getting is:

Object doesn't support property or method 'setValue'".

Is there an alternative for IE7? This works absolutely fine in IE8/9, FF and Chrome.

FishBasketGordo
  • 22,904
  • 4
  • 58
  • 91
Fraser
  • 980
  • 4
  • 13
  • 31
  • 1
    (@epascarello has provided an answer) But I'm curious... as far as I know `setValue` is not a valid method in _any_ browser?! What type of element is "statusFilter"? – MrWhite Mar 27 '12 at 15:46
  • statuFilter is a select object. The developer before me had included some external libraries and setValue essentially replaced .value= – Fraser Mar 28 '12 at 08:31
  • In that case, it looks like `setValue()` would have been provided by the external library. Having since tested this, `setValue()` does not work in any browser by default. It's possible that setValue() provided some additional validation...? – MrWhite Mar 28 '12 at 11:02
  • Just to add... old browsers did not support the `value` property (and apparently [Konqueror does not](http://stackoverflow.com/a/7242613/369434)) so a `setValue()` method might have been required (in the past) for cross browser support. – MrWhite Mar 28 '12 at 12:28
  • Yes, setValue() was definitely added by an external browser. The value property certainly works fine for IE7+ which is what I was looking for. Thanks a lot :) – Fraser Mar 28 '12 at 14:39

1 Answers1

3
document.getElementById("statusFilter").value = "0";
epascarello
  • 204,599
  • 20
  • 195
  • 236