|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Problem in drop down
Hi All,
I have a problem in my drop down list.I have years from 2000 to 2005 in my drop down,what i want is,by default it shud display the current year.If a select a year and submits the form it shud display the selected year.But in my case it returns to the current year.Here i have pasted my piece of code,can any one help me to fix this problem? Drop Down for select year : ----------------------------------------------------------- <select size="1" name="y_year" class="textbox"> <% for i=2002 to year(date) %> <option value="<%=i%>" <%=selyear(i,request("y_year"))%>><%=i%></option> <%next%> </select> -------------------------------------------------------------- Function for displaying the selected year (selyear) --------------------------------------------------------------- Function selyear(Source,requestyear) if requestyear="" then requestyear=0 end if if cint(source)=cint(requestyear) then selyear="selected" else if cint(source)=cint(year(date)) then selyear ="selected" end if end if End Function -------------------------------------------------------------- Can any fix this problem?.OR please show me an alternative way. |
|
#2
|
|||
|
|||
|
Reply:select list problem
Hi
Problem seems to be with the selyear function. Try following in the function . if cint(source)=cint(requestyear) then selyear="selected" else selyear ="" end if Error in your code: Because in the 2nd else if you are checking source with current year and for loop limit is also year(date). So it always selects the last one. brlele |
|
#3
|
|||
|
|||
|
Hi brlele,
But it shud show the current year when the page is loaded,wheres in your modified code it shows up the first record..that is year 2003 as selected. Any Idea??? Quote:
|
|
#4
|
|||
|
|||
|
Hi brlele,
But it shud show the current year when the page is loaded,wheres in your modified code it shows up the first record..that is year 2003 as selected. Any Idea??? |
|
#5
|
|||
|
|||
|
re:dropdown problem
Hi there
take request("y_year") in some variable say temp = request.form("y_year") ' this is after form is posted 'before posting the form temp = year(date()) and now change the html code to following <select size="1" name="y_year" class="textbox"> <% for i=2002 to year(date) %> <option value="<%=i%>" <%=selyear(i,temp )%>><%=i%></option> <%next%> </select> This will help I think. Regards brlele |
|
#6
|
|||
|
|||
|
No it did not work....again it goes back to default year.that is current year 2004.This is the problem what i had first.
|
|
#7
|
|||
|
|||
|
Re: dropdown problem
Hi asp_kid
an you post the entire code for the page? brlele |
|
#8
|
|||
|
|||
|
My code goes like this:
--------------function for selected drop down----------------------- <% dim temp temp = request.form("y_year") Function selyear(source,requestyear) if requestyear="" then requestyear=0 end if if cint(source)=cint(requestyear) then selyear="selected" else selyear="" end if End Function %> -----------form for drop down year:----------------------- <form name='frm' method='post' action='manageform.asp'> <%temp=year(date)%> <select size="1" name="y_year" class="textbox"> <% ' Start a loop to create the years prior and previous for i = 2000 to year(date)%> <option value="<%=i%>" <%=selyear(i,temp)%>><%=i%></option> <% next %> </select> <input type="submit" value="submit"> </form> |
|
#9
|
|||
|
|||
|
I wanted the code of the entire page.
Anyway a pseudo code I am giving here the following code is in xyz.asp '===================================== <% dim temp dim blnIsPageSubmit blnIsPageSubmit = trim(request.form("hidIsSubmit")) if blnIsPageSubmit = "1" then temp = trim(request.form("y_year")) else temp = year(date()) end if %> <form name="frmXXX" action="xyz.asp" method="post"> code for the sel list <input type="hidden" value="1" name="hidIsSubmit"> <input type="submit" value="submit"> </form> <% '=================================== %> Hope you'll get some idea out of this Regards brlele |
|
#10
|
|||
|
|||
|
Hi,
did u check your code?.I copied and tried to run your code.It did not work.What i want is when the page is loaded it show the current year as selected.If i select a year and submits the form.It should show up the year selected. Your code diplays the starting year in the drop down Last edited by asp_kid : February 25th, 2004 at 02:18 AM. Reason: spelling mistake |
|
#11
|
|||
|
|||
|
Hi
I didnt expect you to just copy and paste the code. That is why I mentioned its a pseudo code. The whole idea was to make distinction between page submitted and the same page not submitted. So its better if you can post the code of the entire page you are working on to the forum. Maybe then only one can give suggestions. brlele |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > Problem in drop down |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|