Click here to Skip to main content
15,908,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi...
Im using dropdown for displaying month. If a user choose april after refreshing,it shows as april only. I want to show january even after refreshing the page using javascript...guide me
Posted
Comments
dimpledevani 24-Jul-12 0:51am    
Reload your dropdownlist on page load
Priyaaammu 24-Jul-12 0:53am    
Without using cs code,how to do it only with javascript...

1 solution

HTML
<input type="hidden" name="selectedValue" value="0"/>  

put the above one in just below of your select tag

and do this in your servlet

JavaScript
String selectedValue = `request.getParameter("selectedValue")` 

now set the selectedValue into the servlet request

create a JS function in your final jsp
JavaScript
function selectedValue(){  

    var value =<%=request.getParameter("selectedValue")%>;  
    if(value !=null)  
        {

        document.f1.slvalue.selectedIndex=value ;          

        }    

} 

call the selectedValue() function on bodyload of your final jsp page. "slvalue" is a name of your select tag
Ref.:How to keep Dropdownlist value same after refresh the page[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900