The property of a undefined or null-link cannot be retrieved

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel1111
    New Member
    • Jun 2019
    • 31

    #16
    Hi. I have tried
    Code:
    console.log(filterDropDown)
    to get the content of my selected items in the drop-down-menu. When I am using Firefox the content is correct. When I am using IE I do not get any content. The content is empty. So I think the problem is the Following:
    Code:
    dropdown = document.getElementById('modelRangeDropdown');
    filterDropDown = dropdown.value;
    I think there is a problem with ".value". How else can I get the actual value of my dropdown menu?
    Thanks

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5388

      #17
      probably you should use:

      Code:
      dropdown[dropdown.selectedIndex].value

      Comment

      • Daniel1111
        New Member
        • Jun 2019
        • 31

        #18
        I have tried
        Code:
        filterDropDown = dropdown[dropdown.selectedIndex].value;
        but this is not working too

        Comment

        • gits
          Recognized Expert Moderator Expert
          • May 2007
          • 5388

          #19
          hmmmm - may be going the full path like this works then?

          Code:
          dropdown.options[dropdown.selectedIndex].value
          if not you would need to check if your options have actually values set.

          PS: since it did look weird to me i just tested it on an IE11 now with a static list where the value properties are set - all 3 versions did work - so i guess the listoptions are missing the value-properties in your case somehow.
          Last edited by gits; Jun 17 '19, 08:46 AM.

          Comment

          • Daniel1111
            New Member
            • Jun 2019
            • 31

            #20
            I am now using
            Code:
            filterDropDown = dropdown.options[dropdown.selectedIndex].text;
            This is working.
            So I have to use text instead of value

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5388

              #21
              so in fact your listoptions have no value attribute then - as it turns out - in this case IE is doing it correctly from my point of view - since obviously other browsers just return the text in case no value attribute is present - thus leading to such confusion here. properties shouldn't be silently 'reused' by browsers. Even if i hate to have to say that in favor of IE now :)

              to avoid that issue the best way would be to make sure in your code where the options are created - that you create and assign the value property.
              Last edited by gits; Jun 17 '19, 09:03 AM.

              Comment

              Working...