Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Drop Down refresh keep selected value

Reply
Thread Tools

Drop Down refresh keep selected value

 
 
Patrick
Guest
Posts: n/a
 
      09-02-2004
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
 
Reply With Quote
 
 
 
 
J. J. Cale
Guest
Posts: n/a
 
      09-03-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
 
 
 
Shawn Milo
Guest
Posts: n/a
 
      09-03-2004
What type of page is it? HTML, ASP, PHP, etc.?

Shawn
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1st Drop-down selection determins selected value in all drop-downs In ASP.Net Wizard jaysch ASP .Net 0 04-30-2011 02:19 PM
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Enable second drop down after first drop down is selected teser3@hotmail.com Javascript 0 01-28-2009 12:59 AM
retrive preselected value in second drop down list from the first drop down list weiwei ASP .Net 0 01-05-2007 07:29 PM
New to .NET, can I have one drop down box control the data of another drop down box using a database? SirPoonga ASP .Net 2 01-07-2005 10:44 PM



Advertisments