Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can anyone make asp do this.....? 1

Status
Not open for further replies.
do you mean just to be able to display today's date? or display in european format, or to automatically select today's date in the dropdown list?

 
Javascript version below. Uses Do..While logic to dynamically fill the Select box with current month on top.


function MonthInputBox(MonthValue) {
var time = new Date();
var month = time.getMonth();
var datef = month + 12;
var realJavaScriptMonth = month;
var monthfuture = month + 0;
document.writeln (&quot;<select name=&quot; + MonthValue + &quot;>&quot;);
do {
month = datef;
if (month >= 12) {
month = month - 12;
}
if (month < 0) {
month = month + 12;
}
date = datef - 1;
month = month -1;
realJavaScriptMonth = month + 2;
var realJavaScriptMonth = &quot;&quot; + realJavaScriptMonth;
if (realJavaScriptMonth.length == 1) {
realJavaScriptMonth = &quot;0&quot; + realJavaScriptMonth;
}
var dateNum = realJavaScriptMonth;
document.write (&quot;<OPTION value=\&quot;&quot; + realJavaScriptMonth + &quot;\&quot;>&quot; + dateNum + &quot;&quot;);
}
while (datef > monthfuture)
document.write (&quot;</SELECT>&quot;);
}

Eric

Starting GA/AL Focus User Group (FUSE) in Atlanta. See IBI website for usergroup info or contact me at eric.searing@wcom.com.
 
Thanks Eric - I was hoping to avoid client-side javascript and was wondering if anyone knew how to get the same effect using asp....

Lobstah, it's the selection of todays date in a drop down I'm after if you have any ideas they'd be gratefully received...

 
Here you go my friend. Pure ASP :) First, copy this to a test page on your server and run it.


<%@ Language=VBScript %>
<% Option Explicit %>
<%
dim i
dim j
dim m

'SET THE NUMBER OF MONTHS YOU WANT TO DISPLAY HERE
dim months
months = 5
%>

<html>
<head></head>
<body>
<form>
<select name=&quot;day&quot;>
<%
FOR i = 1 TO 31
m = &quot; &quot;
IF i = DatePart(&quot;d&quot;,Now) THEN
m = &quot; selected &quot;
END IF
%>
<option<%=m%>value=&quot;<%=i%>&quot;><%=i%></option>
<%
NEXT
%>
</select>  
<select name=&quot;monthyear&quot;>
<%
j = Now
FOR i = 1 TO months
%>
<option value=&quot;<%=DatePart(&quot;yyyy&quot;,j)%>_<%=DatePart(&quot;m&quot;,j)%>&quot;><%=MonthName(DatePart(&quot;m&quot;,j))%> <%=DatePart(&quot;yyyy&quot;,j)%></option>
<%
j = DateAdd(&quot;m&quot;, 1, j)
NEXT
%>
</select>
</form>
</body>
</html>


Happy Bookings :)

ToddWW
 
ToddWW, what can I say! Thank you very much - you d'maaan!

:-D

Rich.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top