Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > บทความจากสมาชิก > List วันเกิด Mktime แสดงข้อมูลวันที่ตามวันที่จริง



 
Clound SSD Virtual Server

List วันเกิด Mktime แสดงข้อมูลวันที่ตามวันที่จริง

วันนี้มาดูการสร้างlist วันเกิด กำหนดวัน/เดือน/ปี ตามความเป็นจริงแบบง่ายๆกันครับ เช่น ปีนี้เดือนกุมภาพันธ์ มี 28 วัน ก็แสดง 28วัน และปีไหนมี 29 วันก็แสดง29วัน ตามปีนั้นๆ

Code (PHP)
<?php 
$monthOptions = '';
$dayOptions = '';
$yearOptions = ''; 

for($month=1; $month<=12; $month++)
{
    $monthName = date("M", mktime(0, 0, 0, $month));
	$monthOptions .= "<option value=\"{$month}\">{$monthName}</option>\n";	
}
for($day=1; $day<=31; $day++)
{
    $dayOptions .= "<option value=\"{$day}\">{$day}</option>\n";
}
for($year=2011; $year>=1950; $year--)
{
	$yearOptions .= "<option value=\"{$year}\">{$year}</option>\n";
}
?>
<html>
<head>
<script type="text/javascript">
function updateDays()
{
	//Create variables needed    
	var monthSel = document.getElementById('month');    
	var daySel   = document.getElementById('day');    
	var yearSel  = document.getElementById('year');    
	var monthVal = monthSel.value;    
	var yearVal  = yearSel.value;
	
	//Determine the number of days in the month/year    
	var daysInMonth = 31;    
	if (monthVal==2)    
	{
	daysInMonth = (yearVal%4==0 && (yearVal%100!=0 || yearVal%400==0)) ? 29 : 28;    
	}
	else if (monthVal==4 || monthVal==6 || monthVal==9 || monthVal==11)    
	{
		daysInMonth = 30;    
	}
	
	//Add/remove options from days select list as needed    
	if(daySel.options.length > daysInMonth)
	{   //Remove excess days, if needed        
		daySel.options.length = daysInMonth;    
	}
	while (daySel.options.length != daysInMonth)
	{   //Add additional days, if needed        
		daySel.options[daySel.length] = new Option(daySel.length+1, daySel.length+1, false);    
	}
	
	return;
}
	
</script>
</head>
</html>








   
Share
Bookmark.   

  By : ATVa
  Article : บทความเป็นการเขียนโดยสมาชิก หากมีปัญหาเรื่องลิขสิทธิ์ กรุณาแจ้งให้ทาง webmaster ทราบด้วยครับ
  Score Rating :
  Create Date : 2011-07-08
  Download : No files
Sponsored Links
ThaiCreate.Com Forum


Comunity Forum Free Web Script
Jobs Freelance Free Uploads
Free Web Hosting Free Tools

สอน PHP ผ่าน Youtube ฟรี
สอน Android การเขียนโปรแกรม Android
สอน Windows Phone การเขียนโปรแกรม Windows Phone 7 และ 8
สอน iOS การเขียนโปรแกรม iPhone, iPad
สอน Java การเขียนโปรแกรม ภาษา Java
สอน Java GUI การเขียนโปรแกรม ภาษา Java GUI
สอน JSP การเขียนโปรแกรม ภาษา Java
สอน jQuery การเขียนโปรแกรม ภาษา jQuery
สอน .Net การเขียนโปรแกรม ภาษา .Net
Free Tutorial
สอน Google Maps Api
สอน Windows Service
สอน Entity Framework
สอน Android
สอน Java เขียน Java
Java GUI Swing
สอน JSP (Web App)
iOS (iPhone,iPad)
Windows Phone
Windows Azure
Windows Store
Laravel Framework
Yii PHP Framework
สอน jQuery
สอน jQuery กับ Ajax
สอน PHP OOP (Vdo)
Ajax Tutorials
SQL Tutorials
สอน SQL (Part 2)
JavaScript Tutorial
Javascript Tips
VBScript Tutorial
VBScript Validation
Microsoft Access
MySQL Tutorials
-- Stored Procedure
MariaDB Database
SQL Server Tutorial
SQL Server 2005
SQL Server 2008
SQL Server 2012
-- Stored Procedure
Oracle Database
-- Stored Procedure
SVN (Subversion)
แนวทางการทำ SEO
ปรับแต่งเว็บให้โหลดเร็ว


Hit Link
   







Load balance : Server 02
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่