Drop Down refresh keep selected value

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Patrick

    #1

    Drop Down refresh keep selected value

    Hello,

    I have a drop down list that when a value is selected the page
    refreshes itself but the selected value changes back to the default
    value. I would like to keep the selected value after the page is
    refreshed. any ideas?

    Thanks in advance.

    Patrick
  • J. J. Cale

    #2
    Re: Drop Down refresh keep selected value

    You haven't said how your document is being refreshed. If you are using the
    onchange handler in the select to call a function that repopulates the list
    it shouldn't be a problem. If you are submitting the form and the page is
    being refreshed you should do it server side. For the former
    ----------------------------------------------------
    // Before you repopulate the list trap the selection.
    function yourFunction() {
    var savedIndex = document.forms["your form
    name"].yourSelectList .selectedIndex;
    your code here.........
    // after you repopulate the list, programatically change the selection.
    document.forms["your form
    name"].yourSelectList .options[savedIndex].selected = true;
    }
    ----------------------------------------------------
    // alternatively you could pass it to the function that rewrites the select
    list.
    <select name = "yourSelectList " onchange =
    "yourFunction(t his.selectedInd ex)">
    function yourFunction( savedIndex )
    your code here.......
    document.forms["your form
    name"].yourSelectList .options[savedIndex].selected = true;
    }
    hope that helps

    "Patrick" <patrick.mcdona ld@gmail.com> wrote in message
    news:76cb6ae9.0 409021558.67835 96c@posting.goo gle.com...[color=blue]
    > Hello,
    >
    > I have a drop down list that when a value is selected the page
    > refreshes itself but the selected value changes back to the default
    > value. I would like to keep the selected value after the page is
    > refreshed. any ideas?
    >
    > Thanks in advance.
    >
    > Patrick[/color]


    Comment

    • Shawn Milo

      #3
      Re: Drop Down refresh keep selected value

      What type of page is it? HTML, ASP, PHP, etc.?

      Shawn

      Comment

      Working...