Home > ASP Development > [General - Question] How do I return a date value from a dropdown box?

[General - Question] How do I return a date value from a dropdown box?



Hi,



I want the user to be able to select from 2 dates, today's date and yesterdays date from a dropdown box. Based on what the user chooses, that date is sent to the next page which will request this date to use to query a table. I can't seem to pass it on. I'm pretty new to ASP so please bear with me.



1st page dropdown box:




Code:


<table class="data">
<form name="Center" action="rpt_Status.asp" method=post>

<tr>
<td><b>Date</td>
<td><select style="font-size:10 name=dt>

<option value= "0"></option>
<option value="<%=date()-1%>"><%=date()-1%></option>
<option value="<%=date()%>"><%=date()%></option>

</select>
</td>
</tr>

</table>

<br>
<input type="submit" name="submit" value="Submit">
</form>






2nd page (rpt_Status.asp)




Code:


Dim verified_dt
Dim verified_mth
Dim verified_day
Dim verified_yr

verified_dt = Request.Form("dt")
verified_mth = Month(CDate(verified_dt))
verified_day = Day(CDate(verified_dt))
verified_yr = year(CDate(verified_dt))






rpt_Status.asp needs to know which date was selected so that it can convert it to verified_dt and go through the other conversions. So basically, how can I make it so dt = <%=date()%> or <%=date()-1%> as selected from the dropdown box?



Thanks in advance.

    
Guest


did you just not post the quotes or are they not part of your code


Code:


<select style="font-size:10;" name="dt">



Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by mehere
did you just not post the quotes or are they not part of your code


Code:


<select style="font-size:10;" name="dt">






It is not part of the code, should it be? Is that the only thing holding it up?



Thanks

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by a0f6459
It is not part of the code, should it be? Is that the only thing holding it up?



Thanks




Should be, yes.

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by BLarche
Should be, yes.




I have added the quotes, but <%=date()%> does not seemed to be passed to the next page.



For example if I did this from the first page:



<a href="rpt_Status.asp?dt=<%=date()%>"><%=date()%></a>



rpt_Status.asp works correctly. I just can't get the dropdown to do the very same thing in assigning the dt value of <%=date()%>.



Any ideas?



Thanks

Was this answer helpful ? Yes No   
Guest


Thanks for all your help, it was the select statement that was wrong. I was missing a semicolon.



Again, thanks alot!

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved