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 SkipVought 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
0
0
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!
 
I guess that &quot;selected&quot; gives you the default option:
<SELECT NAME=&quot;reportingperiod&quot;>

<OPTION VALUE=1>Apr 1 - Jun 30</OPTION>
<%
IF DATE >= &quot;July 1&quot; AND <= &quot;September 30&quot; then
response.write (&quot;<OPTION VALUE=2 SELECTED>Jul 1 - Sep 30</OPTION>&quot;)
else
response.write (&quot;<OPTION VALUE=2>Jul 1 - Sep 30</OPTION>&quot;)
end if
...
<OPTION VALUE=3>Oct 1 - Dec 31</OPTION>
<OPTION VALUE=4>Jan 1 - Mar 31</OPTION>
</SELECT>

If none of the options is SELECTED, the first option is selected by default
Let me know if this post was helpfull...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top