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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selected Option based on Date

Status
Not open for further replies.

sysr

Technical User
Aug 17, 2001
17
CA
I would like the appropriate option to be selected based on the current date. I was thinking that there would be an easy way to do this, I can't find it.

IF DATE >= &quot;April 1&quot; AND <= &quot;June 30&quot; THEN ???(Option 1 would be defaulted)
ELSEIF DATE >= &quot;July 1&quot; AND <= &quot;September 30&quot; THEN ???
ELSEIF DATE >= &quot;October 1&quot; AND <= &quot;December 31&quot; THEN ???
ELSE ???
END IF

<SELECT NAME=&quot;reportingperiod&quot;>
<OPTION VALUE=1>Apr 1 - Jun 30</OPTION>
<OPTION VALUE=2>Jul 1 - Sep 30</OPTION>
<OPTION VALUE=3>Oct 1 - Dec 31</OPTION>
<OPTION VALUE=4>Jan 1 - Mar 31</OPTION>
</SELECT>

Thank you!
 
hello sysr
here i send the code for that.using javascript u can do this
<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--

function window_onload() {
var sysdate=new Date()
var tday=sysdate.getDate()
var tmon=sysdate.getMonth()
//note the month starts from 0-11
var year=sysdate.getYear()
alert(tday)
alert(tmon)
alert(year)

if (tmon+1>=4 && tmon+1<=6)
{
select1.value = &quot;1&quot;
}
else if (tmon+1>=7 && tmon+1<=9)
{
select1.value = &quot;2&quot;
}
else if (tmon+1>=10 && tmon+1<=12)
{
select1.value = &quot;3&quot;
}
else if (tmon+1>=1 && tmon+1<=3)
{
select1.value = &quot;4&quot;
}

}

//-->
</SCRIPT>
</HEAD>
<BODY LANGUAGE=javascript onload=&quot;return window_onload()&quot;>

<P>
<SELECT id=select1 name=select1>
<OPTION value=&quot;1&quot;>Apr1-Jun30</OPTION>
<OPTION value=&quot;2&quot;>Jul1-sep30</OPTION>
<OPTION value=&quot;3&quot;>oct1-dec31</OPTION>
<OPTION value=&quot;4&quot;>jan1-mar31</OPTION>
</SELECT>
</P>

</BODY>
</HTML>
-----------
with regards
webspy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top