Drop Down refresh keep selected value

  • Follow


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
0
Reply patrick 9/2/2004 11:58:41 PM

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(this.selectedIndex)">
function yourFunction( savedIndex )
    your code here.......
    document.forms["your form
name"].yourSelectList.options[savedIndex].selected = true;
}
hope that helps

"Patrick" <patrick.mcdonald@gmail.com> wrote in message
news:76cb6ae9.0409021558.6783596c@posting.google.com...
> 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


0
Reply J 9/3/2004 7:50:26 AM


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

Shawn
0
Reply shawn 9/3/2004 11:56:00 AM

2 Replies
1307 Views

(page loaded in 0.053 seconds)

Similiar Articles:













7/19/2012 5:31:43 PM


Reply: