Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Aug 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Problem executing options.selectedIndex IE11

    So I have table where user can select multiple entries and also has a search button. So when the search button is pressed, selected entries in the table are saved and when search is closed, the table will restore with the entries which were selected before + the new searched once. So user doesn't lose existing selected entries. So lets say there are 3 funtions for this. One to find text, one to save selection and one is to restore.

    function SaveSelection (SelectedTable) {

    if ( selectionSaved == false )
    {
    for(var i =0; i<SelectedTable.length; i++)
    {
    storedSelections[i] = SelectedTable.options[i].selected;

    }

    selectionSaved = true;
    return true;
    }
    return false;
    }

    function RestoreSelection (SelectedTable) {

    // saved the current selected index

    var selectedIdx = SelectedTable.options.selectedIndex;

    if ( selectionSaved == true)
    {
    //starting from index 1 to deselect all
    for(var i =1; i<SelectedTable.length; i++)
    {
    //restore the saved selection before findtext
    storedSelections[i] = SelectedTable.options[i].selected;
    }
    //restore the current selected index
    SelectedTable.options[selectedIdx].selected = true;

    }
    //empty the array
    storedSelections = null;
    storedSelections = [];
    selectionSaved = false;
    }

    Saved funtion works fine, infact this whole thing works fine in IE8. But when launched in IE 11 its giving an error. In the Restore function it says
    "Unable to get property 'selectedIndex' of undefined or null reference.

    So what is the alternative of selectedIndex for IE11?

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,354
    Thanks
    23
    Thanked 618 Times in 617 Posts
    JS without HTML is worthless, but where is selectionSaved defined?
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,981
    Thanks
    56
    Thanked 557 Times in 554 Posts
    looks to me like it should be
    var selectedIdx = SelectedTable.selectedIndex;

  • #4
    New to the CF scene
    Join Date
    Aug 2014
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I got it working guys, it was supposed to be (document.formname.selectname) i was only passing the IDname in the function. Funny thing is, in older IE version it worked regardless.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •