Welcome Guest ( Log In | Register)



 
Reply to this topicStart new topic
> Drop Down Lists Using Dates
fsoftball
post Jul 12 2005, 02:43 PM
Post #1


Member [Level 2]
*****

Group: Members
Posts: 78
Joined: 25-April 05
Member No.: 6,158



Hi,

I have a page where the user enters a date. I would like to use drop down boxes for the date. I would like the current date to be the default date. I think that part is pretty easy.

However, I am having trouble listing all of the months. It wills tart at July and end at December. I need to list January through June.

Anyone know a good way to list all the months? I am assuming that I will be able to do the same sort of thing for the date.

Thanks!
Go to the top of the page
 
+Quote Post
palladin
post Jul 12 2005, 03:45 PM
Post #2


Member [Level 3]
******

Group: Members
Posts: 92
Joined: 28-June 05
Member No.: 8,782



Look at this rolleyes.gif

CODE

<?
// Months Start Here
$month[0]="--";
$month[1]="January";
$month[2]="February";
$month[3]="March";
$month[4]="April";
$month[5]="May";
$month[6]="June";
$month[7]="July";
$month[8]="August";
$month[9]="September";
$month[10]="Octobre";
$month[11]="November";
$month[12]="December";
// End Months Start Here

// Days Start Here
$days[0]="Sun";
$days[1]="Mon";
$days[2]="Tues";
$days[3]="Wed";
$days[4]="Thu";
$days[5]="Fri";
$days[6]="Sat";
// End Days Start Here

//Add Month Func.
$dayno=(int)date("w");
// End Add Month Func.

//Add Month Func.
$monno=(int)date("m");
// End Add Month Func.

// Show date on the page.
echo $days[$dayno]." ".$month[$monno]." ".date("d")."/".date("Y");
// End Show date on the page.
?>




--------------------

Practice is when evrything is work but no one know why.
Theory is when work nothing but evry one know why.
Programmers join Practice with Theory - nothing work and no one know why cool.gif
Go to the top of the page
 
+Quote Post
fsoftball
post Jul 14 2005, 05:55 PM
Post #3


Member [Level 2]
*****

Group: Members
Posts: 78
Joined: 25-April 05
Member No.: 6,158



Thanks palladin. While that is helpful, it isn't really what I'm looking.

Here is a snip of the code I currently use:

echo "<SELECT name='month'>\n";
echo "<option value ='Apr'>April</option>\n";
echo "<option value ='May'>May</option>\n";
echo "<option value ='June'>June</option>\n";
echo "<option value ='July'>July</option>\n";
echo "<option value ='August'>August</option>\n";
echo "</select>\n";
echo "&nbsp;&nbsp;&nbsp;\n";

I want 'June' to be the top month displayed, but I do not want to loose 'Apr' and 'May'. This might be an html question rather than a PHP question.
Go to the top of the page
 
+Quote Post
sachavdk
post Jul 15 2005, 12:41 AM
Post #4


Member [Level 1]
****

Group: Members
Posts: 62
Joined: 11-July 05
Member No.: 9,266



Maybe this is what you want:

CODE
<html>
<body>
<select name="datum">
<?
$date = getdate();
for ($i=$date[0];$i<=($date[0]+31536000);$i+=86400)
{
echo "<option value=\"".date("Y/d/m H:i:s",$i)."\">".date("Y/d/m H:i:s",$i)."</option>";
}
?>
</select>
</body>
</html>


the list orders the dates from the day the list is called (ie when you're testing the script) until today next year. if you don't want today next year to be listed use in the code instead of 31536000 this number: 31449600.
The date is written in the format YYYY/DD/MM HH:MM:SS (year/day/month hour:minute:second). You can change it if you want. If you want to use other look here http://be.php.net/manual/en/function.date.php.
You only have to change the formatting "Y/d/m H:i:s" to ie "d/m/Y" but remember with this script you have to do it twice. Once for the value and once for the one that is written in de dropdownlist.

If anything doesn't work like you want please ask
Go to the top of the page
 
+Quote Post
palladin
post Jul 15 2005, 12:44 AM
Post #5


Member [Level 3]
******

Group: Members
Posts: 92
Joined: 28-June 05
Member No.: 8,782



Hmm you mean wanna select June as default ?
CODE

echo "<SELECT name='month'>\n";
echo "<option value ='Apr'>April</option>\n";
echo "<option value ='May'>May</option>\n";
echo "<option [B]selected[/B] value ='June'>June</option>\n";
echo "<option value ='July'>July</option>\n";
echo "<option value ='August'>August</option>\n";
echo "</select>\n";
echo "&nbsp;&nbsp;&nbsp;\n";


Use selected after otpion and combo box will set a June as default without touching them.


--------------------

Practice is when evrything is work but no one know why.
Theory is when work nothing but evry one know why.
Programmers join Practice with Theory - nothing work and no one know why cool.gif
Go to the top of the page
 
+Quote Post
fsoftball
post Jul 15 2005, 05:39 PM
Post #6


Member [Level 2]
*****

Group: Members
Posts: 78
Joined: 25-April 05
Member No.: 6,158



That is what I'm looking for palladin. But I can' seem to get it to to work. do I need eto do somethingmore thatn simply add the selected to that option?

When I do it, shouldn't that month be displayed in the drop down menu?

Thanks again.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Gt4 Online?(6)
  2. Seeking Help With Javascript(1)
  3. Adding Drop Down Menus(6)
  4. Msgbox(17)
  5. Java Script Drop Down Menu With Css(2)
  6. Website Drop Shadow Effect Help(7)
  7. Multiple Drop Down Menus W/ Submit Button(6)
  8. Drop Shipping(3)
  9. Multiple Drop Down Lists ?(4)
  10. Easy Summer Cookings And Shopping Lists(1)
  11. Lists, Unordered And Nested(2)
  12. Editing Drop Down Menu In Php(3)
  13. Mu Online Server 97j+ds(0)
  14. Definition Lists To Display Artist, Cd, And Track(0)
  15. Free Web Hosts(1)
  1. Asking Girls Out On Dates(15)
  2. Custom Drop Down Menu's(4)
  3. How To Solve Increasing Menu Navigation Lists(5)
  4. Blood/water Ripples, Blood/water Drop Waves.(0)
  5. The Elder Scrolls Iv Oblivion(8)
  6. Image Roll Over Drop Down Menu Help(2)
  7. Dynamic Drop Down List <select>(3)
  8. Looking For Flash Tutorial Site(5)
  9. Mailing Lists(1)
  10. Quality Expiring Domain Name Lists(1)
  11. Make Dl Drop Its Margin(7)
  12. Mailing Lists(1)
  13. Dynamic Drop Down Lists(0)
  14. Affiliate Programs Directory(5)
  15. Review Dan Spot!(13)


 



- Lo-Fi Version Time is now: 30th August 2008 - 02:09 AM