ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 24th, 2004, 11:10 PM
asp_kid asp_kid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: India
Posts: 21 asp_kid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 24 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old February 24th, 2004, 11:29 PM
brlele brlele is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 91 brlele User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 21 m 2 sec
Reputation Power: 5
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

Reply With Quote
  #3  
Old February 25th, 2004, 12:45 AM
asp_kid asp_kid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: India
Posts: 21 asp_kid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 24 sec
Reputation Power: 0
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:
Originally Posted by brlele
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

Reply With Quote
  #4  
Old February 25th, 2004, 12:53 AM
asp_kid asp_kid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: India
Posts: 21 asp_kid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 24 sec
Reputation Power: 0
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???

Reply With Quote
  #5  
Old February 25th, 2004, 12:56 AM
brlele brlele is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 91 brlele User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 21 m 2 sec
Reputation Power: 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

Reply With Quote
  #6  
Old February 25th, 2004, 01:06 AM
asp_kid asp_kid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: India
Posts: 21 asp_kid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 24 sec
Reputation Power: 0
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.

Reply With Quote
  #7  
Old February 25th, 2004, 01:13 AM
brlele brlele is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 91 brlele User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 21 m 2 sec
Reputation Power: 5
Re: dropdown problem

Hi asp_kid
an you post the entire code for the page?

brlele

Reply With Quote
  #8  
Old February 25th, 2004, 01:25 AM
asp_kid asp_kid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: India
Posts: 21 asp_kid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 24 sec
Reputation Power: 0
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>

Reply With Quote
  #9  
Old February 25th, 2004, 01:47 AM
brlele brlele is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 91 brlele User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 21 m 2 sec
Reputation Power: 5
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

Reply With Quote
  #10  
Old February 25th, 2004, 02:15 AM
asp_kid asp_kid is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Location: India
Posts: 21 asp_kid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 48 m 24 sec
Reputation Power: 0
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

Reply With Quote
  #11  
Old February 25th, 2004, 02:39 AM
brlele brlele is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 91 brlele User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 21 m 2 sec
Reputation Power: 5
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

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Problem in drop down


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT