<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>บทความ PHP AJAX CSS Javascript MySql jQuery</title><link>http://www.ninenik.com</link><description>รวมบทความ PHP Ajax css javascript jQuery เว็บไซต์สำเร็จรูป CMSPro</description><language>th-TH</language><lastBuildDate>Sun, 05 Feb 2012 17:53:43 +0700</lastBuildDate><copyright>Copyright ninenik.com</copyright><image><title>CMSPro เว็บไซต์สำเร็จรูป</title><url>http://www.ninenik.com/images/logo_ninenik.gif</url><link>http://www.ninenik.com</link></image><item><title>แสดง icons กำหนดรูปเอง ให้จุดเริ่มเต้น และสิ้นสุดของเส้นทาง ใน google map อย่างง่าย</title><link>http://www.ninenik.com/แสดง_icons_กำหนดรูปเอง_ให้จุดเริ่มเต้น_และสิ้นสุดของเส้นทาง_ใน_google_map_อย่างง่าย-430.html</link><description><![CDATA[<p>&nbsp;ประยุกต์จากเนื้อหา&nbsp;</p>
<div>DirectionsService DirectionsRenderer ค้นหา และสร้าง เส้นทางใน google map</div>
<div><a href="http://www.ninenik.com/content.php?arti_id=340">http://www.ninenik.com/content.php?arti_id=340</a></div>
<div>&nbsp;</div>
<div>โดยอยู่ภายใต้เงื่อนไข คือจุดเริ่มต้น และสิ้นสุด จะไม่สามารถลากเพื่อ เปลี่ยนเส้นทางได้</div>
<div>&nbsp;</div>
<div><strong>ตัวอย่าง</strong></div>
<div>&nbsp;</div>
<div><style type="text/css">
/* css กำหนดความกว้าง ความสูงของแผนที่ */
#map_canvas { 
	width:550px;
	height:400px;
	margin:auto;
	margin-top:50px;
}
</style>
<div id="map_canvas">&nbsp;</div>
<div id="showDD" style="margin:auto;padding-top:5px;width:550px;"><!--textbox กรอกชื่อสถานที่ และปุ่มสำหรับการค้นหา เอาไว้นอกแท็ก <form>--> From:  <input name="namePlace" type="text" id="namePlace" size="60" /> <br />
To: <input name="toPlace" type="text" id="toPlace" size="60" /> <input type="button" name="SearchPlace" id="SearchPlace" value="Search" /> <input type="button" name="iClear" id="iClear" value="Clear" />   <hr />
<!--  <form> เก็บข้อมูลสำหรับนำไปบันทึกลงฐานข้อมูล หรือนำไปใช้อื่นๆ-->
<form id="form_get_detailMap" name="form_get_detailMap" method="post" action="">
    From:  <input name="namePlaceGet" type="text" id="namePlaceGet" size="60" /> <br />
    To: <input name="toPlaceGet" type="text" id="toPlaceGet" size="60" /><br />
    ระยะทางข้อความ   <input name="distance_text" type="text" id="distance_text" value="" size="17" /> ระยะทางตัวเลข  <input name="distance_value" type="text" id="distance_value" value="0" size="17" /> เมตร<br />
    ระยะเวลาข้อความ <input name="duration_text" type="text" id="duration_text" size="15" /> ระยะเวลาตัวเลข <input name="duration_value" type="text" id="duration_value" value="0" size="17" /> วินาที <input type="submit" name="button" id="button" value="บันทึก" />     <br />
    * ระยะทางโดยประมาณ ระยะเวลา กรณีขับรถ โดยประมาณ
    <p id="myconsole">&nbsp;</p>
</form>
</div>
<script type="text/javascript">
var directionShow; // กำหนดตัวแปรสำหรับใช้งาน กับการสร้างเส้นทาง
var directionsService; // กำหนดตัวแปรสำหรับไว้เรียกใช้ข้อมูลเกี่ยวกับเส้นทาง
var map; // กำหนดตัวแปร map ไว้ด้านนอกฟังก์ชัน เพื่อให้สามารถเรียกใช้งาน จากส่วนอื่นได้
var GGM; // กำหนดตัวแปร GGM ไว้เก็บ google.maps Object จะได้เรียกใช้งานได้ง่ายขึ้น
var my_Latlng; // กำหนดตัวแปรสำหรับเก็บจุดเริ่มต้นของเส้นทางเมื่อโหลดครั้งแรก
var initialTo; // กำหนดตัวแปรสำหรับเก็บจุดปลายทาง เมื่อโหลดครั้งแรก
var searchRoute; // กำหนดตัวแปร ไว้เก็บฃื่อฟังก์ชั้น ให้สามารถใช้งานจากส่วนอื่นๆ ได้
var makeMarker; // 
var icons;
function initialize() { // ฟังก์ชันแสดงแผนที่
	GGM=new Object(google.maps); // เก็บตัวแปร google.maps Object ไว้ในตัวแปร GGM
	
	// Start/Finish icons
	icons = {
		start: new GGM.MarkerImage(
		// URL
		'http://google-maps-icons.googlecode.com/files/walking-tour.png',
		// (width,height)
		new GGM.Size( 44, 32 ),
		// The origin point (x,y)
		new GGM.Point( 0, 0 ),
		// The anchor point (x,y)
		new GGM.Point( 22, 32 )
		),
		end: new GGM.MarkerImage(
		// URL
		'http://google-maps-icons.googlecode.com/files/spring-hot.png',
		// (width,height)
		new GGM.Size( 44, 32 ),
		// The origin point (x,y)
		new GGM.Point( 0, 0 ),
		// The anchor point (x,y)
		new GGM.Point( 22, 32 )
		)
	};
		
	directionShow=new  GGM.DirectionsRenderer({suppressMarkers:true});
//	directionShow=new  GGM.DirectionsRenderer({
//		draggable:true,
//		markerOptions:{
//			  draggable: true,
//			  raiseOnDrag: false,			 
//			  dragCrossMove:true
//		}
//	});	
	
	directionsService = new GGM.DirectionsService();
	// กำหนดจุดเริ่มต้นของแผนที่
	my_Latlng  = new GGM.LatLng(13.761728449950002,100.6527900695800);
	// กำหนดตำแหน่งปลายทาง สำหรับการโหลดครั้งแรก
	initialTo=new GGM.LatLng(13.8129355,100.7316899); 
	var my_mapTypeId=GGM.MapTypeId.ROADMAP; // กำหนดรูปแบบแผนที่ที่แสดง
	// กำหนด DOM object ที่จะเอาแผนที่ไปแสดง ที่นี้คือ div id=map_canvas
	var my_DivObj=$("#map_canvas")[0];
	// กำหนด Option ของแผนที่
	var myOptions = {
		zoom: 13, // กำหนดขนาดการ zoom
		center: my_Latlng , // กำหนดจุดกึ่งกลาง จากตัวแปร my_Latlng
		mapTypeId:my_mapTypeId // กำหนดรูปแบบแผนที่ จากตัวแปร my_mapTypeId
	};
	map = new GGM.Map(my_DivObj,myOptions); // สร้างแผนที่และเก็บตัวแปรไว้ในชื่อ map
	directionShow.setMap(map); // กำหนดว่า จะให้มีการสร้างเส้นทางในแผนที่ที่ชื่อ map
	
	if(map){ // เงื่่อนไขถ้ามีการสร้างแผนที่แล้ว
		 searchRoute(my_Latlng,initialTo); // ให้เรียกใช้ฟังก์ชัน สร้างเส้นทาง
	}
	
	// กำหนด event ให้กับเส้นทาง กรณีเมื่อมีการเปลี่ยนแปลง 
	GGM.event.addListener(directionShow, 'directions_changed', function() {
		var results=directionShow.directions; // เรียกใช้งานข้อมูลเส้นทางใหม่ 
			
		// นำข้อมูลต่างๆ มาเก็บในตัวแปรไว้ใช้งาน
		var addressStart=results.routes[0].legs[0].start_address; // สถานที่เริ่มต้น
		var addressEnd=results.routes[0].legs[0].end_address;// สถานที่ปลายทาง
		var distanceText=results.routes[0].legs[0].distance.text; // ระยะทางข้อความ
		var distanceVal=results.routes[0].legs[0].distance.value;// ระยะทางตัวเลข
		var durationText=results.routes[0].legs[0].duration.text; // ระยะเวลาข้อความ
		var durationVal=results.routes[0].legs[0].duration.value; // ระยะเวลาตัวเลข		
		// นำค่าจากตัวแปรไปแสดงใน textbox ที่ต้องการ
		$("#namePlaceGet").val(addressStart);
		$("#toPlaceGet").val(addressEnd);
		$("#distance_text").val(distanceText);
		$("#distance_value").val(distanceVal);
		$("#duration_text").val(durationText);
		$("#duration_value").val(durationVal);		
	});


}
$(function(){
	// ส่วนของฟังก์ชัน สำหรับการสร้างเส้นทาง
	searchRoute=function(FromPlace,ToPlace){ // ฟังก์ชัน สำหรับการสร้างเส้นทาง
		if(!FromPlace && !ToPlace){ // ถ้าไม่ได้ส่งค่าเริ่มต้นมา ให้ใฃ้ค่าจากการค้นหา
			var FromPlace=$("#namePlace").val();// รับค่าชื่อสถานที่เริ่มต้น
			var ToPlace=$("#toPlace").val(); // รับค่าชื่อสถานที่ปลายทาง
		}
		// กำหนด option สำหรับส่งค่าไปให้ google ค้นหาข้อมูล
		var request={
			origin:FromPlace, // สถานที่เริ่มต้น
			destination:ToPlace, // สถานที่ปลายทาง
			travelMode: GGM.DirectionsTravelMode.DRIVING // กรณีการเดินทางโดยรถยนต์
		};
		// ส่งคำร้องขอ จะคืนค่ามาเป็นสถานะ และผลลัพธ์
		directionsService.route(request, function(results, status){
			if(status==GGM.DirectionsStatus.OK){ // ถ้าสามารถค้นหา และสร้างเส้นทางได้
				directionShow.setDirections(results); // สร้างเส้นทางจากผลลัพธ์


//				console.log(directionShow);
//				console.log(results.routes[0].legs[0]);
//				directionShow.markerOptions.icon=icons.start;				
//				directionShow.markerOptions.icon=icons.end;		
				var leg = results.routes[0].legs[0];
				makeMarker(leg.start_location, icons.start, "title" );
				makeMarker(leg.end_location, icons.end, 'title' );				
				
				// นำข้อมูลต่างๆ มาเก็บในตัวแปรไว้ใช้งาน 
				var addressStart=results.routes[0].legs[0].start_address; // สถานที่เริ่มต้น
				var addressEnd=results.routes[0].legs[0].end_address;// สถานที่ปลายทาง
				var distanceText=results.routes[0].legs[0].distance.text; // ระยะทางข้อความ
				var distanceVal=results.routes[0].legs[0].distance.value;// ระยะทางตัวเลข
				var durationText=results.routes[0].legs[0].duration.text; // ระยะเวลาข้อความ
				var durationVal=results.routes[0].legs[0].duration.value; // ระยะเวลาตัวเลข		
				// นำค่าจากตัวแปรไปแสดงใน textbox ที่ต้องการ
				$("#namePlaceGet").val(addressStart);
				$("#toPlaceGet").val(addressEnd);
				$("#distance_text").val(distanceText);
				$("#distance_value").val(distanceVal);
				$("#duration_text").val(durationText);
				$("#duration_value").val(durationVal);		
				// ส่วนการกำหนดค่านี้ จะกำหนดไว้ที่ event direction changed ที่เดียวเลย ก็ได้
			}else{
				// กรณีไม่พบเส้นทาง หรือไม่สามารถสร้างเส้นทางได้
				// โค้ดตามต้องการ ในทีนี้ ปล่อยว่าง
			}
		});
	}
	
	// ส่วนควบคุมปุ่มคำสั่งใช้งานฟังก์ชัน
	$("#SearchPlace").click(function(){ // เมื่อคลิกที่ปุ่ม id=SearchPlace 
		searchRoute();	// เรียกใช้งานฟังก์ชัน ค้นหาเส้นทาง
	});

	$("#namePlace,#toPlace").keyup(function(event){ // เมื่อพิมพ์คำค้นหาในกล่องค้นหา
		if(event.keyCode==13 && $(this).val()!=""){	// 	ตรวจสอบปุ่มถ้ากด ถ้าเป็นปุ่ม Enter 
			searchRoute();		// เรียกใช้งานฟังก์ชัน ค้นหาเส้นทาง
		}		
	});
	
	$("#iClear").click(function(){
		$("#namePlace,#toPlace").val(""); // ล้างค่าข้อมูล สำหรับพิมพ์คำค้นหาใหม่
	});


	makeMarker=function(position,icon,title){
		 new GGM.Marker({
//			  draggable: true,
//			  raiseOnDrag: false,			 
//			  dragCrossMove:true,
			  position: position,
			  map: map,
			  icon: icon,
			  title: title
		 });
	}

	
});
$(function(){
	// โหลด สคริป google map api เมื่อเว็บโหลดเรียบร้อยแล้ว
	// ค่าตัวแปร ที่ส่งไปในไฟล์ google map api
	// v=3.2&sensor=false&language=th&callback=initialize
	//	v เวอร์ชัน่ 3.2
	//	sensor กำหนดให้สามารถแสดงตำแหน่งทำเปิดแผนที่อยู่ได้ เหมาะสำหรับมือถือ ปกติใช้ false
	//	language ภาษา th ,en เป็นต้น
	//	callback ให้เรียกใช้ฟังก์ชันแสดง แผนที่ initialize	
	$("<script/>", {
	  "type": "text/javascript",
	  src: "http://maps.google.com/maps/api/js?v=3.2&sensor=false&language=th&callback=initialize"
	}).appendTo("body");	
});
</script></div>
<div>&nbsp;</div>
<div><strong>โค้ดทั้งหมด</strong></div>
<pre name="code" class="php:controls">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; 
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Google Map API 3 - 01&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
html { height: 100% }
body { 
	height:100%;
	margin:0;padding:0;
	font-family:tahoma, &quot;Microsoft Sans Serif&quot;, sans-serif, Verdana;
	font-size:12px;
}
/* css กำหนดความกว้าง ความสูงของแผนที่ */
#map_canvas { 
	width:550px;
	height:400px;
	margin:auto;
	margin-top:50px;
}
&lt;/style&gt;


&lt;/head&gt;

&lt;body&gt;
  &lt;div id=&quot;map_canvas&quot;&gt;&lt;/div&gt;
 &lt;div id=&quot;showDD&quot; style=&quot;margin:auto;padding-top:5px;width:550px;&quot;&gt;  
&lt;!--textbox กรอกชื่อสถานที่ และปุ่มสำหรับการค้นหา เอาไว้นอกแท็ก &lt;form&gt;--&gt;
From: 
&lt;input name=&quot;namePlace&quot; type=&quot;text&quot; id=&quot;namePlace&quot; size=&quot;60&quot; /&gt;
&lt;br /&gt;
To:
&lt;input name=&quot;toPlace&quot; type=&quot;text&quot; id=&quot;toPlace&quot; size=&quot;60&quot; /&gt;
&lt;input type=&quot;button&quot; name=&quot;SearchPlace&quot; id=&quot;SearchPlace&quot; value=&quot;Search&quot; /&gt;
&lt;input type=&quot;button&quot; name=&quot;iClear&quot; id=&quot;iClear&quot; value=&quot;Clear&quot; /&gt;
  &lt;hr /&gt;
&lt;!--  &lt;form&gt; เก็บข้อมูลสำหรับนำไปบันทึกลงฐานข้อมูล หรือนำไปใช้อื่นๆ--&gt;
&lt;form id=&quot;form_get_detailMap&quot; name=&quot;form_get_detailMap&quot; method=&quot;post&quot; action=&quot;&quot;&gt;
From: 
&lt;input name=&quot;namePlaceGet&quot; type=&quot;text&quot; id=&quot;namePlaceGet&quot; size=&quot;60&quot; /&gt;
&lt;br /&gt;
To:
&lt;input name=&quot;toPlaceGet&quot; type=&quot;text&quot; id=&quot;toPlaceGet&quot; size=&quot;60&quot; /&gt;&lt;br /&gt;
ระยะทางข้อความ  
&lt;input name=&quot;distance_text&quot; type=&quot;text&quot; id=&quot;distance_text&quot; value=&quot;&quot; size=&quot;17&quot; /&gt;
ระยะทางตัวเลข 
&lt;input name=&quot;distance_value&quot; type=&quot;text&quot; id=&quot;distance_value&quot; value=&quot;0&quot; size=&quot;17&quot; /&gt;
เมตร&lt;br /&gt;
ระยะเวลาข้อความ
&lt;input name=&quot;duration_text&quot; type=&quot;text&quot; id=&quot;duration_text&quot; size=&quot;15&quot; /&gt;
ระยะเวลาตัวเลข
&lt;input name=&quot;duration_value&quot; type=&quot;text&quot; id=&quot;duration_value&quot; value=&quot;0&quot; size=&quot;17&quot; /&gt;
วินาที
&lt;input type=&quot;submit&quot; name=&quot;button&quot; id=&quot;button&quot; value=&quot;บันทึก&quot; /&gt;  
  &lt;br /&gt;
  * ระยะทางโดยประมาณ ระยะเวลา กรณีขับรถ โดยประมาณ
  &lt;p id=&quot;myconsole&quot;&gt;&lt;/p&gt;
&lt;/form&gt;  
&lt;/div&gt; 

&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;    
&lt;script type=&quot;text/javascript&quot;&gt;
var directionShow; // กำหนดตัวแปรสำหรับใช้งาน กับการสร้างเส้นทาง
var directionsService; // กำหนดตัวแปรสำหรับไว้เรียกใช้ข้อมูลเกี่ยวกับเส้นทาง
var map; // กำหนดตัวแปร map ไว้ด้านนอกฟังก์ชัน เพื่อให้สามารถเรียกใช้งาน จากส่วนอื่นได้
var GGM; // กำหนดตัวแปร GGM ไว้เก็บ google.maps Object จะได้เรียกใช้งานได้ง่ายขึ้น
var my_Latlng; // กำหนดตัวแปรสำหรับเก็บจุดเริ่มต้นของเส้นทางเมื่อโหลดครั้งแรก
var initialTo; // กำหนดตัวแปรสำหรับเก็บจุดปลายทาง เมื่อโหลดครั้งแรก
var searchRoute; // กำหนดตัวแปร ไว้เก็บฃื่อฟังก์ชั้น ให้สามารถใช้งานจากส่วนอื่นๆ ได้
var makeMarker; // 
var icons;
function initialize() { // ฟังก์ชันแสดงแผนที่
	GGM=new Object(google.maps); // เก็บตัวแปร google.maps Object ไว้ในตัวแปร GGM
	
	// Start/Finish icons
	icons = {
		start: new GGM.MarkerImage(
		// URL
		'http://google-maps-icons.googlecode.com/files/walking-tour.png',
		// (width,height)
		new GGM.Size( 44, 32 ),
		// The origin point (x,y)
		new GGM.Point( 0, 0 ),
		// The anchor point (x,y)
		new GGM.Point( 22, 32 )
		),
		end: new GGM.MarkerImage(
		// URL
		'http://google-maps-icons.googlecode.com/files/spring-hot.png',
		// (width,height)
		new GGM.Size( 44, 32 ),
		// The origin point (x,y)
		new GGM.Point( 0, 0 ),
		// The anchor point (x,y)
		new GGM.Point( 22, 32 )
		)
	};
		
	directionShow=new  GGM.DirectionsRenderer({suppressMarkers:true});
//	directionShow=new  GGM.DirectionsRenderer({
//		draggable:true,
//		markerOptions:{
//			  draggable: true,
//			  raiseOnDrag: false,			 
//			  dragCrossMove:true
//		}
//	});	
	
	directionsService = new GGM.DirectionsService();
	// กำหนดจุดเริ่มต้นของแผนที่
	my_Latlng  = new GGM.LatLng(13.761728449950002,100.6527900695800);
	// กำหนดตำแหน่งปลายทาง สำหรับการโหลดครั้งแรก
	initialTo=new GGM.LatLng(13.8129355,100.7316899); 
	var my_mapTypeId=GGM.MapTypeId.ROADMAP; // กำหนดรูปแบบแผนที่ที่แสดง
	// กำหนด DOM object ที่จะเอาแผนที่ไปแสดง ที่นี้คือ div id=map_canvas
	var my_DivObj=$(&quot;#map_canvas&quot;)[0];
	// กำหนด Option ของแผนที่
	var myOptions = {
		zoom: 13, // กำหนดขนาดการ zoom
		center: my_Latlng , // กำหนดจุดกึ่งกลาง จากตัวแปร my_Latlng
		mapTypeId:my_mapTypeId // กำหนดรูปแบบแผนที่ จากตัวแปร my_mapTypeId
	};
	map = new GGM.Map(my_DivObj,myOptions); // สร้างแผนที่และเก็บตัวแปรไว้ในชื่อ map
	directionShow.setMap(map); // กำหนดว่า จะให้มีการสร้างเส้นทางในแผนที่ที่ชื่อ map
	
	if(map){ // เงื่่อนไขถ้ามีการสร้างแผนที่แล้ว
		 searchRoute(my_Latlng,initialTo); // ให้เรียกใช้ฟังก์ชัน สร้างเส้นทาง
	}
	
	// กำหนด event ให้กับเส้นทาง กรณีเมื่อมีการเปลี่ยนแปลง 
	GGM.event.addListener(directionShow, 'directions_changed', function() {
		var results=directionShow.directions; // เรียกใช้งานข้อมูลเส้นทางใหม่ 
			
		// นำข้อมูลต่างๆ มาเก็บในตัวแปรไว้ใช้งาน
		var addressStart=results.routes[0].legs[0].start_address; // สถานที่เริ่มต้น
		var addressEnd=results.routes[0].legs[0].end_address;// สถานที่ปลายทาง
		var distanceText=results.routes[0].legs[0].distance.text; // ระยะทางข้อความ
		var distanceVal=results.routes[0].legs[0].distance.value;// ระยะทางตัวเลข
		var durationText=results.routes[0].legs[0].duration.text; // ระยะเวลาข้อความ
		var durationVal=results.routes[0].legs[0].duration.value; // ระยะเวลาตัวเลข		
		// นำค่าจากตัวแปรไปแสดงใน textbox ที่ต้องการ
		$(&quot;#namePlaceGet&quot;).val(addressStart);
		$(&quot;#toPlaceGet&quot;).val(addressEnd);
		$(&quot;#distance_text&quot;).val(distanceText);
		$(&quot;#distance_value&quot;).val(distanceVal);
		$(&quot;#duration_text&quot;).val(durationText);
		$(&quot;#duration_value&quot;).val(durationVal);		
	});


}
$(function(){
	// ส่วนของฟังก์ชัน สำหรับการสร้างเส้นทาง
	searchRoute=function(FromPlace,ToPlace){ // ฟังก์ชัน สำหรับการสร้างเส้นทาง
		if(!FromPlace &amp;&amp; !ToPlace){ // ถ้าไม่ได้ส่งค่าเริ่มต้นมา ให้ใฃ้ค่าจากการค้นหา
			var FromPlace=$(&quot;#namePlace&quot;).val();// รับค่าชื่อสถานที่เริ่มต้น
			var ToPlace=$(&quot;#toPlace&quot;).val(); // รับค่าชื่อสถานที่ปลายทาง
		}
		// กำหนด option สำหรับส่งค่าไปให้ google ค้นหาข้อมูล
		var request={
			origin:FromPlace, // สถานที่เริ่มต้น
			destination:ToPlace, // สถานที่ปลายทาง
			travelMode: GGM.DirectionsTravelMode.DRIVING // กรณีการเดินทางโดยรถยนต์
		};
		// ส่งคำร้องขอ จะคืนค่ามาเป็นสถานะ และผลลัพธ์
		directionsService.route(request, function(results, status){
			if(status==GGM.DirectionsStatus.OK){ // ถ้าสามารถค้นหา และสร้างเส้นทางได้
				directionShow.setDirections(results); // สร้างเส้นทางจากผลลัพธ์


//				console.log(directionShow);
//				console.log(results.routes[0].legs[0]);
//				directionShow.markerOptions.icon=icons.start;				
//				directionShow.markerOptions.icon=icons.end;		
				var leg = results.routes[0].legs[0];
				makeMarker(leg.start_location, icons.start, &quot;title&quot; );
				makeMarker(leg.end_location, icons.end, 'title' );				
				
				// นำข้อมูลต่างๆ มาเก็บในตัวแปรไว้ใช้งาน 
				var addressStart=results.routes[0].legs[0].start_address; // สถานที่เริ่มต้น
				var addressEnd=results.routes[0].legs[0].end_address;// สถานที่ปลายทาง
				var distanceText=results.routes[0].legs[0].distance.text; // ระยะทางข้อความ
				var distanceVal=results.routes[0].legs[0].distance.value;// ระยะทางตัวเลข
				var durationText=results.routes[0].legs[0].duration.text; // ระยะเวลาข้อความ
				var durationVal=results.routes[0].legs[0].duration.value; // ระยะเวลาตัวเลข		
				// นำค่าจากตัวแปรไปแสดงใน textbox ที่ต้องการ
				$(&quot;#namePlaceGet&quot;).val(addressStart);
				$(&quot;#toPlaceGet&quot;).val(addressEnd);
				$(&quot;#distance_text&quot;).val(distanceText);
				$(&quot;#distance_value&quot;).val(distanceVal);
				$(&quot;#duration_text&quot;).val(durationText);
				$(&quot;#duration_value&quot;).val(durationVal);		
				// ส่วนการกำหนดค่านี้ จะกำหนดไว้ที่ event direction changed ที่เดียวเลย ก็ได้
			}else{
				// กรณีไม่พบเส้นทาง หรือไม่สามารถสร้างเส้นทางได้
				// โค้ดตามต้องการ ในทีนี้ ปล่อยว่าง
			}
		});
	}
	
	// ส่วนควบคุมปุ่มคำสั่งใช้งานฟังก์ชัน
	$(&quot;#SearchPlace&quot;).click(function(){ // เมื่อคลิกที่ปุ่ม id=SearchPlace 
		searchRoute();	// เรียกใช้งานฟังก์ชัน ค้นหาเส้นทาง
	});

	$(&quot;#namePlace,#toPlace&quot;).keyup(function(event){ // เมื่อพิมพ์คำค้นหาในกล่องค้นหา
		if(event.keyCode==13 &amp;&amp; $(this).val()!=&quot;&quot;){	// 	ตรวจสอบปุ่มถ้ากด ถ้าเป็นปุ่ม Enter 
			searchRoute();		// เรียกใช้งานฟังก์ชัน ค้นหาเส้นทาง
		}		
	});
	
	$(&quot;#iClear&quot;).click(function(){
		$(&quot;#namePlace,#toPlace&quot;).val(&quot;&quot;); // ล้างค่าข้อมูล สำหรับพิมพ์คำค้นหาใหม่
	});


	makeMarker=function(position,icon,title){
		 new GGM.Marker({
//			  draggable: true,
//			  raiseOnDrag: false,			 
//			  dragCrossMove:true,
			  position: position,
			  map: map,
			  icon: icon,
			  title: title
		 });
	}

	
});
$(function(){
	// โหลด สคริป google map api เมื่อเว็บโหลดเรียบร้อยแล้ว
	// ค่าตัวแปร ที่ส่งไปในไฟล์ google map api
	// v=3.2&amp;sensor=false&amp;language=th&amp;callback=initialize
	//	v เวอร์ชัน่ 3.2
	//	sensor กำหนดให้สามารถแสดงตำแหน่งทำเปิดแผนที่อยู่ได้ เหมาะสำหรับมือถือ ปกติใช้ false
	//	language ภาษา th ,en เป็นต้น
	//	callback ให้เรียกใช้ฟังก์ชันแสดง แผนที่ initialize	
	$(&quot;&lt;script/&gt;&quot;, {
	  &quot;type&quot;: &quot;text/javascript&quot;,
	  src: &quot;http://maps.google.com/maps/api/js?v=3.2&amp;sensor=false&amp;language=th&amp;callback=initialize&quot;
	}).appendTo(&quot;body&quot;);	
});
&lt;/script&gt;  
&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>]]></description><pubDate>Thu, 26 Jan 2012 14:18:19 +0700</pubDate></item><item><title>แนวทางการประยุกต์ การซ่อน แสดงเนื้อหาสำหรับล็อกอิน อย่างง่าย ด้วย jQuery</title><link>http://www.ninenik.com/แนวทางการประยุกต์_การซ่อน_แสดงเนื้อหาสำหรับล็อกอิน_อย่างง่าย_ด้วย_jQuery-429.html</link><description><![CDATA[<p>&nbsp;ตัวอย่างโค้ดสำหรับการซ่อน แสดงเนื้อหา ประยุกต์แสดงส่วนสำหรับล็อกอิน</p>
<div>ไว้ส่วนบนของเว็บไซต์ แสดง หรือซ่อนเมื่อคลิกที่ลิ้งค์ โดยใช้คำสั่ง slideToggle ของ jQuery</div>
<div>สามารถนำไปดัดแปลง css และการจัดวางตำแหน่งต่างๆ ได้ตามต้องการ</div>
<div>&nbsp;</div>
<div><strong>ตัวอย่าง</strong></div>
<div>&nbsp;</div>
<div><a href="http://www.ninenik.com/demo/jquery_slide_down_up.php">http://www.ninenik.com/demo/jquery_slide_down_up.php</a></div>
<div>&nbsp;</div>
<div><strong>ตัวอย่างโค้ดทั้งหมด</strong></div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; 
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;slde down up&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body{
	padding:0px;
	margin:0px;	
}
div#login_div{
	position:relative;
	margin:auto;
	display:none;
	width:100%;	
	height:150px;
	background-color:#FFFFCC;
}
div#main_div{
	position:relative;
	display:block;
	margin:auto;
	width:970px;
	height:1000px;	
	background-color:#FFCCCC;	
}
&lt;/style&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;div id=&quot;login_div&quot;&gt;
ส่วนของเนื้อหาสำหรับล็อกอิน
&lt;/div&gt;
&lt;div id=&quot;main_div&quot;&gt;
&lt;div id=&quot;login_anchor&quot;&gt;
&lt;a id=&quot;login_anchor_a&quot; href=&quot;#&quot;&gt;เข้าสู่ระบบ / สมัครสมาชิก&lt;/a&gt;
&lt;/div&gt;

&lt;/div&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;    
&lt;script type=&quot;text/javascript&quot;&gt;    
$(function(){    
	$(&quot;#login_anchor_a&quot;).click(function(){
		$(&quot;#login_div&quot;).slideToggle();
	});
});    
&lt;/script&gt; 
&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>]]></description><pubDate>Mon, 23 Jan 2012 09:47:58 +0700</pubDate></item><item><title>รู้จัก และใช้งาน DATEDIFF() ใน mysql ฟังก์ชัน เทียบช่วงเวลาที่เหลือ</title><link>http://www.ninenik.com/รู้จัก_และใช้งาน_DATEDIFF()_ใน_mysql_ฟังก์ชัน_เทียบช่วงเวลาที่เหลือ-428.html</link><description><![CDATA[<p>&nbsp;datediff() เป็น ฟังก์ชันเกี่ยวกับวันที่ของ mysql ใช้สำหรับหาค่าต่างของวันที่สองวันที่</p>
<div>&nbsp;</div>
<div><strong>ตัวอย่าง</strong></div>
<div>&nbsp;</div>
<pre name="code" class="sql:controls">
SELECT DATEDIFF(&quot;2012-01-12&quot;,NOW()) 
// วันที่ปัจจุบันคือ 2012-01-11 คือค่า NOW()
// ค่าที่ได้จะเท่ากับ 1 ได้จาก วันที่แรก ลบด้วย วันที่ที่สอง
// 2012-01-12  ลบ ด้วย 2012-01-11 คือได้ค่าต่างกัน 1 วัน
// อธิบายได้ว่า วันที่แรกมากกว่าวันที่ที่สอง 1 วัน</pre>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><strong>ตัวอย่างถ้ากำหนดวันที่แรก น้อยกว่าวันที่ที่สอง ค่าที่ได้จะติดลบ</strong></div>
<div>&nbsp;</div>
<pre name="code" class="sql:controls">
SELECT DATEDIFF(NOW(),&quot;2012-01-12&quot;) 
// วันที่ปัจจุบันคือ 2012-01-11 คือค่า NOW()
// ค่าที่ได้จะเท่ากับ -1 ได้จาก วันที่แรก ลบด้วย วันที่ที่สอง
// 2012-01-11  ลบ ด้วย 2012-01-12 คือได้ค่าต่างกัน 1 วัน แต่มีเครื่องหมาย - 
// (ติดลบกำหนดว่า วันที่แรกน้อยกว่าวันที่ที่สองอยู่ 1 วัน)</pre>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><strong><u>แนวทางการนำไปใช้งาน</u></strong></div>
<div>&nbsp;</div>
<div><strong>การลบรายการที่เลยวันที่กำหนดมาแล้ว 3 วัน</strong></div>
<div>&nbsp;</div>
<pre name="code" class="sql:controls">
DELETE FROM table WHERE DATEDIFF(date_field,NOW())&gt;=3 
// คำสั่งลบรายการที่ วันที่ date_field มากกว่าวันที่ปัจจุบัน ตั้งแต่ 3 วันขึ้นไป
//  (date_field คือวันที่ที่ใช้ตรวจสอบ มีรูปแบบ 0000-00-00 เช่น 2012-01-05)
// การทำงานคือ หลังจาก 3 วันนับจากวันที่กำหนด date_field รายการนั้นๆ ก็จะถูกลบ</pre>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><strong>การเลือกรายการที่วันที่ ก่อนครบกำหนด 7 วัน&nbsp;</strong></div>
<div>&nbsp;</div>
<pre name="code" class="sql:controls">
SELECT * FROM table WHERE DATEDIFF(NOW(),date_field)=-7 
// คำสั่งเลือกรายการ ที่จะครบกำหนดวันที่ date_field ในอีก 7 วัน
// (date_field คือวันที่ที่ใช้ตรวจสอบ มีรูปแบบ 0000-00-00 เช่น 2012-01-05)
// ในกรณีนี้ date_field คือวันที่ที่จะครบกำหนด
// การทำงานคือ ถ้าอีก 7 วันนับจากวันนี้ จนถึงวันที่ครบกำหนด date_field รายการก็จะถูกนำมาแสดง</pre>
<div>&nbsp;</div>]]></description><pubDate>Wed, 11 Jan 2012 15:40:10 +0700</pubDate></item><item><title>ใช้ jQuery กับ CSS สร้างเมนูย่อย แนวนอน รูปแบบคล้ายแท็บเมนู </title><link>http://www.ninenik.com/ใช้_jQuery_กับ_CSS_สร้างเมนูย่อย_แนวนอน_รูปแบบคล้ายแท็บเมนู_-427.html</link><description><![CDATA[<p>&nbsp;ตัวอย่าง และโค้ดต่อไปนี้ เป็นแนวทางสำหรับสร้างเมนู สำหรับเว็บไซต์ โดยจะมีเมนูย่อยแสดง</p>
<div>เมื่อเลื่อนเมาส์ไปที่เมนูหลักของเมนูย่อยนั้น สามารถนำไปประยุกต์ หรือปรับแต่ง css ให้สวยงาม</div>
<div>ได้ตามต้องการ &nbsp;</div>
<div>&nbsp;</div>
<div><strong>ตัวอย่าง</strong></div>
<div>&nbsp;</div>
<div><style type="text/css">
/* CSS ส่วนแถบแนวทั้งหมดของเมนูหลัก */
ul#top_nav_menu{
	position:relative;
	display:block;
	width:900px;
	height:35px;
	padding:0px;
	margin:0px;
	list-style:none;	
	background-color:#99CCCC;
	overflow:visible;
	line-height:35px;
}
/* css ส่วนของเมนูหลัก */
ul#top_nav_menu li{
	background-color:#FFCC33;
	position:relative;
	display:block;
	float:left;
	height:35px;
	padding:0px 15px;
	margin:0px;
	list-style:none;	
}
ul#top_nav_menu li a{
	text-decoration:none;	
	text-transform:uppercase;
}
/* css ส่วนของแถบแนวทั้งหมดของเมนูย่อย */
ul#top_nav_menu li ul{
	background-color:#CC99CC;	
	position:absolute;
	clear:both;
	float:left;
	top:35px;
	left:0px;
	display:none;
	height:35px;
	width:900px;	
	padding:0px;
	margin:0px;
	list-style:none;		
}
/* css ส่วนของเมนูย่อย */
ul#top_nav_menu li ul li{
	position:relative;
	background-color:#CCCC66;	
	float:left;
	display:block;
	height:35px;
	padding:0px 15px;
	margin:0px;
	list-style:none;	
}
</style>
<div>
<ul id="top_nav_menu">
    <li><a href="#">Home</a></li>
    <li><a href="#">Project Info</a>
    <ul>
        <li><a href="#"><span>Concept</span></a></li>
        <li><a href="#"><span>Fact Sheet</span></a></li>
        <li><a href="#"><span>Facilities</span></a></li>
        <li><a href="#"><span>Floor Plan</span></a></li>
        <li><a href="#"><span>Unit Layout</span></a></li>
        <li>&nbsp;</li>
    </ul>
    </li>
    <li><a href="#">Location</a></li>
    <li><a href="#">Gallery</a></li>
    <li><a href="#">Promotion</a></li>
    <li><a href="#">Buyer's Guide</a></li>
    <li><a href="#">Siri Service</a></li>
    <li><a href="#">Contact us</a>
    <ul>
        <li><a href="#"><span>Concept</span></a></li>
        <li><a href="#"><span>Fact Sheet</span></a></li>
        <li><a href="#"><span>Facilities</span></a></li>
        <li><a href="#"><span>Floor Plan</span></a></li>
    </ul>
    </li>
</ul>
</div>
<script type="text/javascript">  
$(function(){  
	$("ul#top_nav_menu li").hover(function(){	
		var offsetLeft=$(this).position().left;
		$(this).find("ul").css("left",-offsetLeft+"px").delay(300).slideDown(100);
	},function(){
		$(this).find("ul").stop(true,true).slideUp(100);
	});
});  
</script></div>
<div>&nbsp;</div>
<div><strong>โค้อตัวอย่างทั้งหมด</strong></div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body{
	font: Tahoma, Thonburi;	
	font-size:12px;
}
/* CSS ส่วนแถบแนวทั้งหมดของเมนูหลัก */
ul#top_nav_menu{
	position:relative;
	display:block;
	width:900px;
	height:35px;
	padding:0px;
	margin:0px;
	list-style:none;	
	background-color:#99CCCC;
	overflow:visible;
	line-height:35px;
}
/* css ส่วนของเมนูหลัก */
ul#top_nav_menu li{
	background-color:#FFCC33;
	position:relative;
	display:block;
	float:left;
	height:35px;
	padding:0px 15px;
	margin:0px;
	list-style:none;	
}
ul#top_nav_menu li a{
	text-decoration:none;	
	text-transform:uppercase;
}
/* css ส่วนของแถบแนวทั้งหมดของเมนูย่อย */
ul#top_nav_menu li ul{
	background-color:#CC99CC;	
	position:absolute;
	clear:both;
	float:left;
	top:35px;
	left:0px;
	display:none;
	height:35px;
	width:900px;	
	padding:0px;
	margin:0px;
	list-style:none;		
}
/* css ส่วนของเมนูย่อย */
ul#top_nav_menu li ul li{
	position:relative;
	background-color:#CCCC66;	
	float:left;
	display:block;
	height:35px;
	padding:0px 15px;
	margin:0px;
	list-style:none;	
}
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;


&lt;div&gt;

&lt;ul id=&quot;top_nav_menu&quot;&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
			&lt;a href=&quot;#&quot;&gt;Project Info&lt;/a&gt;
			&lt;ul&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Concept&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Fact Sheet&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Facilities&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Floor Plan&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Unit Layout&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot; target=&quot;_blank&quot;&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Location&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Gallery&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Promotion&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Buyer's Guide&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Siri Service&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;
        &lt;a href=&quot;#&quot;&gt;Contact us&lt;/a&gt;
 			&lt;ul&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Concept&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Fact Sheet&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Facilities&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span&gt;Floor Plan&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;       
        &lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;    
    
    
&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;  
&lt;script type=&quot;text/javascript&quot;&gt;  
$(function(){  
	$(&quot;ul#top_nav_menu li&quot;).hover(function(){	
		var offsetLeft=$(this).position().left;
		$(this).find(&quot;ul&quot;).css(&quot;left&quot;,-offsetLeft+&quot;px&quot;).delay(300).slideDown(100);
	},function(){
		$(this).find(&quot;ul&quot;).stop(true,true).slideUp(100);
	});
});  
&lt;/script&gt;    
&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>]]></description><pubDate>Fri, 16 Dec 2011 16:47:47 +0700</pubDate></item><item><title>การใช้งาน css จัดตำแหน่ง ซ้อนข้อความบนรูปภาพอย่างง่าย</title><link>http://www.ninenik.com/การใช้งาน_css_จัดตำแหน่ง_ซ้อนข้อความบนรูปภาพอย่างง่าย-426.html</link><description><![CDATA[<p>&nbsp;ตัวอย่างโค้ดและคำแนะนำต่อไปนี้ เป็นวิธีการใช้งาน css ในการกำหนดตำแหน่ง</p>
<div>ของข้อมูลที่ต้องการแสดง ซ้อนทับ บนรูปภาพที่ต้องการ โดยสามารถนำไปประยุกต์</div>
<div>เพิ่มเติมให้เหมาะกับรูปแบบตามต้องการได้</div>
<div>&nbsp;</div>
<div><strong>ตัวอย่าง</strong></div>
<div>&nbsp;</div>
<div>

<style type="text/css">
.holder_wrap{
	position:relative;
	margin:auto;
	display:block;
	height:120px; /* กำหนดความสูงส่วนพื้นที่คลุมเนื้อหาทั้งหมด */
}
.holder_wrap_img{
	position:absolute;/* กำหนดการจัดตำแหน่งส่วนพื้นที่คลุมเนื้อหารุปและข้อความซ้อนทับ */
}
.holder_wrap_img img{
	position:relative; /* กำหนดการจัดตำแหน่งของรูป */
}
/* css ซ้อนทับ ชิดขอบบน */
.inner_position_top{
	position:absolute;
	display:block;	
	background-color:#CC99FF;	
	height:50px; /* กำหนดความสูงส่วนของเนื้อหาที่นำมาซ้อนทับ */
	width:100%; /* กำหนดความกว้างของเนื้อหาที่นำมาซ้อนทับ แบบขยายเต็ม */
	top:0px; /* css กำหนดชิดขวา  */
	z-index:999;
}
/* css ซ้อนทับ ชิดขอบด้านซ้าย */
.inner_position_left{
	position:absolute;
	display:block;	
	background-color:#99FFCC;	
	height:100%;/* กำหนดความสูงส่วนของเนื้อหาที่นำมาซ้อนทับ แบบขยายเต็ม */
	width:50px; /* กำหนดความกว้างของเนื้อหาที่นำมาซ้อนทับ */
	top:0px; /* css กำหนดชิดด้านบน  */
	left:0px; /* css กำหนดชิดขวา  */
	z-index:999;
}
/* css ซ้อนทับ ชิดขอบล่าง */
.inner_position_bottom{
	position:absolute;
	display:block;	
	background-color:#FFCCCC;	
	height:50px; /* กำหนดความสูงส่วนของเนื้อหาที่นำมาซ้อนทับ */
	width:100%; /* กำหนดความกว้างของเนื้อหาที่นำมาซ้อนทับ แบบขยายเต็ม */
	bottom:0px; /* css กำหนดชิดด้านล่าง  */
	z-index:999;	
}
/* css ซ้อนทับ ชิดขอบด้านขวา */
.inner_position_right{
	position:absolute;
	display:block;	
	background-color:#FFFF99;	
	height:100%;/* กำหนดความสูงส่วนของเนื้อหาที่นำมาซ้อนทับ แบบขยายเต็ม */
	width:50px; /* กำหนดความกว้างของเนื้อหาที่นำมาซ้อนทับ */
	top:0px; /* css กำหนดชิดด้านบน  */
	right:0px; /* css กำหนดชิดขวา  */
	z-index:999;
}
</style>


<div class="holder_wrap">
<div class="holder_wrap_img">
<img src="http://www.ninenik.com/userfiles/12/image/1.jpg" />
<div class="inner_position_top">
ซ้อนทับ ชิดขอบบน
</div>
</div>
</div>

<br style="clear:both;float:left;" />


<div class="holder_wrap">
<div class="holder_wrap_img">
<img src="http://www.ninenik.com/userfiles/12/image/1.jpg" />
<div class="inner_position_left">
ซ้อนทับ ชิดขอบซ้าย
</div>
</div>
</div>

<br style="clear:both;float:left;" />


<div class="holder_wrap">
<div class="holder_wrap_img">
<img src="http://www.ninenik.com/userfiles/12/image/1.jpg" />
<div class="inner_position_bottom">
ซ้อนทับ ชิดขอบล่าง
</div>
</div>
</div>

<br style="clear:both;float:left;" />

<div class="holder_wrap">
<div class="holder_wrap_img">
<img src="http://www.ninenik.com/userfiles/12/image/1.jpg" />
<div class="inner_position_right">
ซ้อนทับ ชิดขอบขวา
</div>
</div>
</div>

</div>
<div>&nbsp;</div>
<div><strong>ตัวอย่างโค้ดทั้งหมด</strong></div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; 
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;&lt;/title&gt;

&lt;style type=&quot;text/css&quot;&gt;
.holder_wrap{
	position:relative;
	margin:auto;
	display:block;
	height:120px; /* กำหนดความสูงส่วนพื้นที่คลุมเนื้อหาทั้งหมด */
}
.holder_wrap_img{
	position:absolute;/* กำหนดการจัดตำแหน่งส่วนพื้นที่คลุมเนื้อหารุปและข้อความซ้อนทับ */
}
.holder_wrap_img img{
	position:relative; /* กำหนดการจัดตำแหน่งของรูป */
}
/* css ซ้อนทับ ชิดขอบบน */
.inner_position_top{
	position:absolute;
	display:block;	
	background-color:#CC99FF;	
	height:50px; /* กำหนดความสูงส่วนของเนื้อหาที่นำมาซ้อนทับ */
	width:100%; /* กำหนดความกว้างของเนื้อหาที่นำมาซ้อนทับ แบบขยายเต็ม */
	top:0px; /* css กำหนดชิดด้านบน  */
	z-index:999;
}
/* css ซ้อนทับ ชิดขอบด้านซ้าย */
.inner_position_left{
	position:absolute;
	display:block;	
	background-color:#99FFCC;	
	height:100%;/* กำหนดความสูงส่วนของเนื้อหาที่นำมาซ้อนทับ แบบขยายเต็ม */
	width:50px; /* กำหนดความกว้างของเนื้อหาที่นำมาซ้อนทับ */
	top:0px; /* css กำหนดชิดด้านบน  */
	left:0px; /* css กำหนดชิดซ้าย  */
	z-index:999;
}
/* css ซ้อนทับ ชิดขอบล่าง */
.inner_position_bottom{
	position:absolute;
	display:block;	
	background-color:#FFCCCC;	
	height:50px; /* กำหนดความสูงส่วนของเนื้อหาที่นำมาซ้อนทับ */
	width:100%; /* กำหนดความกว้างของเนื้อหาที่นำมาซ้อนทับ แบบขยายเต็ม */
	bottom:0px; /* css กำหนดชิดด้านล่าง  */
	z-index:999;	
}
/* css ซ้อนทับ ชิดขอบด้านขวา */
.inner_position_right{
	position:absolute;
	display:block;	
	background-color:#FFFF99;	
	height:100%;/* กำหนดความสูงส่วนของเนื้อหาที่นำมาซ้อนทับ แบบขยายเต็ม */
	width:50px; /* กำหนดความกว้างของเนื้อหาที่นำมาซ้อนทับ */
	top:0px; /* css กำหนดชิดด้านบน  */
	right:0px; /* css กำหนดชิดขวา  */
	z-index:999;
}
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;



&lt;div class=&quot;holder_wrap&quot;&gt;
&lt;div class=&quot;holder_wrap_img&quot;&gt;
&lt;img src=&quot;http://www.ninenik.com/userfiles/12/image/1.jpg&quot; /&gt;
&lt;div class=&quot;inner_position_top&quot;&gt;
ซ้อนทับ ชิดขอบบน
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;br style=&quot;clear:both;float:left;&quot; /&gt;


&lt;div class=&quot;holder_wrap&quot;&gt;
&lt;div class=&quot;holder_wrap_img&quot;&gt;
&lt;img src=&quot;http://www.ninenik.com/userfiles/12/image/1.jpg&quot; /&gt;
&lt;div class=&quot;inner_position_left&quot;&gt;
ซ้อนทับ ชิดขอบซ้าย
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;br style=&quot;clear:both;float:left;&quot; /&gt;


&lt;div class=&quot;holder_wrap&quot;&gt;
&lt;div class=&quot;holder_wrap_img&quot;&gt;
&lt;img src=&quot;http://www.ninenik.com/userfiles/12/image/1.jpg&quot; /&gt;
&lt;div class=&quot;inner_position_bottom&quot;&gt;
ซ้อนทับ ชิดขอบล่าง
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;br style=&quot;clear:both;float:left;&quot; /&gt;

&lt;div class=&quot;holder_wrap&quot;&gt;
&lt;div class=&quot;holder_wrap_img&quot;&gt;
&lt;img src=&quot;http://www.ninenik.com/userfiles/12/image/1.jpg&quot; /&gt;
&lt;div class=&quot;inner_position_right&quot;&gt;
ซ้อนทับ ชิดขอบขวา
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;




&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>]]></description><pubDate>Tue, 06 Dec 2011 16:32:39 +0700</pubDate></item><item><title>แนวทางการสร้างเมนูหลายภาษา อย่างง่ายด้วย php และ javascript</title><link>http://www.ninenik.com/แนวทางการสร้างเมนูหลายภาษา_อย่างง่ายด้วย_php_และ_javascript-425.html</link><description><![CDATA[<p>&nbsp;ตัวอย่างโค้ดต่อไปนี้ เป็นแนวทางอย่างง่าย สำหรับนำไปประยุกต์ใช้งานการสร้างเว็บไซต์ เมนูหลายภาษา</p>
<div>โดยอาศัยการใช้การกำหนดตัวแปรแบบ Constants ด้วยคำสั่ง define() ใน php&nbsp;</div>
<div>สำหรับการปรับแต่งหรือความต้องการที่เหนือกว่านี้ จำเป็นต้องอาศัยพื้นฐาน หรือทักษะอื่นๆ เพิ่มเติม</div>
<div>ประกอบในการนำไปประยุกต์ใช้งาน</div>
<div>&nbsp;</div>
<div><strong>ดูตัวอย่างได้ที่</strong></div>
<div><a href="http://www.ninenik.com/demo/multilang/">http://www.ninenik.com/demo/multilang/</a></div>
<div>&nbsp;</div>
<div><strong>ตัวอย่างไฟล์ จะมีแค่ 3 ไฟล์ 2 โฟลเดอร์</strong></div>
<div>1.index.php ไฟล์หลักสำหรับทดสอบการแสดง</div>
<div>2.en/index.php ไฟล์สำหรับเมนูภาษาอังกฤษ</div>
<div>3.th/index.php &nbsp;ไฟล์สำหรับเมนูภาษาไทย</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><strong>1.index.php ไฟล์หลักสำหรับทดสอบการแสดง</strong></div>
<pre name="code" class="php:controls">
&lt;?php
// ส่วนกำหนดสำหรับการเรียกใช้เมนูภาษา ตามที่ผู้ใช้เลือก กรณีเริ่มต้น จะเป็นภาษาอังกฤษ
$pathLang=(!isset($_COOKIE['ck_lang']) || $_COOKIE['ck_lang']==&quot;&quot;)?&quot;en&quot;:$_COOKIE['ck_lang'];
include($pathLang.&quot;/index.php&quot;);
?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; 
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;


&lt;div style=&quot;margin:auto;width:600px;&quot;&gt;
&lt;br /&gt;
&lt;a href=&quot;javascript:setLang('th');&quot;&gt;Thai&lt;/a&gt;
&lt;a href=&quot;javascript:setLang('en');&quot;&gt;Eng&lt;/a&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;#&quot;&gt;&lt;?=_Home?&gt;&lt;/a&gt; |  
&lt;a href=&quot;#&quot;&gt;&lt;?=_About_Us?&gt;&lt;/a&gt; |  
&lt;a href=&quot;#&quot;&gt;&lt;?=_Contact_Us?&gt;&lt;/a&gt; 

 &lt;/div&gt;




&lt;script type=&quot;text/javascript&quot;&gt;
function setLang(langID){ //ฟังก์ชัน javascript สำหรับกำหนด ตัวแปร cookie ภาษา
	var days=365; // กำหนดจำนวนวันที่ต้องการให้จำค่า  
	var date = new Date();  
	date.setTime(date.getTime()+(days*24*60*60*1000));  
	var expires = &quot;; expires=&quot;+date.toGMTString();  
	document.cookie = &quot;ck_lang=&quot; +langID+ &quot;; expires=&quot; + expires + &quot;; path=/&quot;;  
	window.location.reload()
}
&lt;/script&gt;
 
&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>
<div><strong>2.en/index.php ไฟล์สำหรับเมนูภาษาอังกฤษ</strong></div>
<pre name="code" class="php:controls">
&lt;?php
define(&quot;_Home&quot;,&quot;Home&quot;);
define(&quot;_About_Us&quot;,&quot;About Us&quot;);
define(&quot;_Contact_Us&quot;,&quot;Contact Us&quot;);
?&gt;</pre>
<div>&nbsp;</div>
<div><strong>3.th/index.php &nbsp;ไฟล์สำหรับเมนูภาษาไทย</strong></div>
<pre name="code" class="php:controls">
&lt;?php
define(&quot;_Home&quot;,&quot;หน้าแรก&quot;);
define(&quot;_About_Us&quot;,&quot;เกี่ยวกับเรา&quot;);
define(&quot;_Contact_Us&quot;,&quot;ติดต่อเรา&quot;);
?&gt;</pre>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><strong>ดาวโหลดไฟล์ตัวอย่าง อย่างง่าย ได้ที่</strong></div>
<div><a href="http://www.ninenik.com/download/multilang.rar">http://www.ninenik.com/download/multilang.rar</a></div>]]></description><pubDate>Wed, 09 Nov 2011 11:59:58 +0700</pubDate></item><item><title>การเชื่อมต่อ facebook และ ล็อกอิน แบบ popup ด้วย php sdk v.3.1.1</title><link>http://www.ninenik.com/การเชื่อมต่อ_facebook_และ_ล็อกอิน_แบบ_popup_ด้วย_php_sdk_v.3.1.1-424.html</link><description><![CDATA[<p>&nbsp;แนวทางการประยุกต์ การเชื่อมต่อ facebook ด้วย php sdk v.3.1.1 แบบสร้าง ล็อกอิน</p>
<div>แบบ popup window ด้วย javascript</div>
<div>&nbsp;</div>
<div>โดยจะเป็นการประยุกต์ใช้งานจากเนื้อหาเดิม ตามลิ้งค์ด้านล่าง</div>
<div>&nbsp;</div>
<div><a target="_blank" href="http://www.ninenik.com/content.php?arti_id=423">http://www.ninenik.com/content.php?arti_id=423</a></div>
<div>&nbsp;</div>
<div>รูปแบบการทำงานคือ เมื่อทำการคลิกที่ลิ้งค์ สำหรับล็อกอินด้วย facebook ก็จะเปิดหน้า popup</div>
<div>สำหรับกรอกชื่อผู้ใช้ หรือรหัสผ่าน กรณียังไม่ได้ล็อกอิน facebook อยู่ หลังจาก ล็อกอินเสร็จแล้ว</div>
<div>จะลิ้งค์ไปอีกหน้าหนึ่ง สำหรับสร้างค่า session และเช็ค สถานะการล็อกอิน ของผู้ใช้งาน&nbsp;</div>
<div>แล้วปิดหน้า popup นั้นลง พร้อมกับรีโหลดหน้าหลัก เป็นต้น</div>
<div>&nbsp;</div>
<div>ดาวน์โหลดไฟล์ทดสอบ ไปปรับใช้ได้ที่</div>
<div><a target="_blank" href="http://www.ninenik.com/fb/fb3.1.1popup.rar">http://www.ninenik.com/fb/fb3.1.1popup.rar</a></div>
<div>&nbsp;</div>
<div>หรือทดสอบตัวอย่างก่อนโหลด</div>
<div><a target="_blank" href="http://www.ninenik.com/fb/fb3.1.1/test_login_popup.php">http://www.ninenik.com/fb/fb3.1.1/test_login_popup.php</a></div>
<div>&nbsp;</div>
<div>ไฟล์โค้ดตัวอย่าง ที่เกี่ยวข้อง</div>
<div>&nbsp;</div>
<div><strong>ไฟล์&nbsp;test_login_popup.php</strong></div>
<pre name="code" class="php:controls">
&lt;?php
include(&quot;fb_connect_popup.php&quot;);
?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; 
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:fb=&quot;http://www.facebook.com/2008/fbml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Sample FB Login Popup&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;?php
//pre($fb_user);
?&gt;
&lt;h1&gt;php-sdk 3.1.1&lt;/h1&gt;

&lt;?php if($fb_user){ // ถ้ามีการล็อกอิน facebook อยู่แล้ว แสดงลิ้งค์สำหรับ logout ?&gt;
	&lt;a href=&quot;&lt;?=$logoutUrl?&gt;&quot;&gt;Logout&lt;/a&gt;
&lt;?php }else{ //  ถ้ายังไม่ได้ล็อกอิน แสดงลิ้งค์สำหรับ Login ?&gt;
    &lt;div&gt;
    Login using OAuth 2.0 handled by the PHP SDK:
    &lt;a href=&quot;javascript:popup('&lt;?=$loginUrl?&gt;','',500,350);&quot;&gt;Login with Facebook&lt;/a&gt;
    &lt;/div&gt;
&lt;?php } ?&gt;


    &lt;h3&gt;PHP Session&lt;/h3&gt;
    &lt;pre&gt;&lt;?php print_r($_SESSION); ?&gt;&lt;/pre&gt;

&lt;?php if($fb_user){ // ถ้ามีการล็อกอิน facebook อยู่แล้ว แสดงข้อมูลของคนๆ นั้น ?&gt;
      &lt;h3&gt;You&lt;/h3&gt;
      &lt;img src=&quot;https://graph.facebook.com/&lt;?=$fb_user?&gt;/picture&quot;&gt;

      &lt;h3&gt;Your User Object (/me)&lt;/h3&gt;
      &lt;?php 
	  pre($fb_userData); 
	  ?&gt;
      
&lt;?php }else{ //  ถ้ายังไม่ได้ล็อกอิน  ?&gt;
      &lt;strong&gt;&lt;em&gt;You are not Connected.&lt;/em&gt;&lt;/strong&gt;

&lt;?php } ?&gt;


&lt;script type=&quot;text/javascript&quot;&gt;
function popup(url,name,windowWidth,windowHeight){    
	myleft=(screen.width)?(screen.width-windowWidth)/2:100;	
	mytop=(screen.height)?(screen.height-windowHeight)/2:100;	
	properties = &quot;width=&quot;+windowWidth+&quot;,height=&quot;+windowHeight;
	properties +=&quot;,scrollbars=yes, top=&quot;+mytop+&quot;,left=&quot;+myleft;   
	window.open(url,name,properties);
}
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>
<div><strong>ไฟล์&nbsp;fb_connect_popup.php</strong></div>
<pre name="code" class="php:controls">
&lt;?php
session_start(); // กำหนดไว้ กรณีอาจได้ใช้ตัวแปร session
include(&quot;inc/facebook.php&quot;); //  เรียกใช้งานไฟล์ php-sdk สำหรับ facebook
//
$facebook = new Facebook(array(
  'appId'  =&gt; 'xxxxxx', // appid ที่ได้จาก facebook
  'secret' =&gt; 'xxxxxxxx',  // app secret ที่ได้จาก facebook
  'fileUpload' =&gt; true, // เปิดใช้ในส่วนของการอัพโหลดรูปได้
  'cookie' =&gt; true, // อนุญาตใช้งาน cookie  
));
// สร้างฟังก์ชันไว้สำหรัดทดสอบ การแสดงผลการใช้งาน
function pre($varUse){
	echo &quot;&lt;pre&gt;&quot;;
	print_r($varUse);
	echo &quot;&lt;/pre&gt;&quot;;
}
// Get User ID
$fb_user = $facebook-&gt;getUser();
if($fb_user){
  try{
    // Proceed knowing you have a logged in user who's authenticated.
    $fb_userData=$facebook-&gt;api('/me');
  }catch(FacebookApiException $e) {
    error_log($e);
    $user=null;
  }
}
if(isset($_GET['logout'])){ // ทำการ logout อย่างสมบูรณ์
	$facebook-&gt;destroySession(null); 	// ล่างค่า session ของ facebook
	header(&quot;Location:&quot;.$_SERVER['PHP_SELF']); //ลิ้งค์ไปหน้าที่ต้องการเมื่อ logout เรียบร้อยแล้ว
}
// Login or logout url will be needed depending on current user state.
if($fb_user){
  $logoutUrl = $facebook-&gt;getLogoutUrl(array(
  	&quot;next&quot;=&gt;&quot;http://www.ninenik.com/fb/fb3.1.1/test_login_popup.php?logout&quot;
  ));
} else{
  $loginUrl = $facebook-&gt;getLoginUrl(array(
  	&quot;redirect_uri&quot;=&gt;&quot;http://www.ninenik.com/fb/fb3.1.1/fb_checklogin.php&quot;,
	&quot;display&quot;=&gt;&quot;popup&quot;,
	&quot;scope&quot;=&gt;&quot;offline_access,publish_stream,email&quot; // คั่นแต่ละค่าด้วย ,(comma
  ));
}
?&gt;</pre>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>
<div><strong>ไฟล์&nbsp;fb_checklogin.php</strong></div>
<pre name="code" class="php:controls">
&lt;?php
include(&quot;fb_connect_popup.php&quot;);
?&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;Check Login&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
window.opener.location.reload();
window.close();
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>
</div>
</div>
<div>&nbsp;</div>]]></description><pubDate>Fri, 14 Oct 2011 11:49:11 +0700</pubDate></item><item><title>แนะนำการใช้งาน การเชื่อมต่อ facebook ด้วย php sdk v.3.1.1</title><link>http://www.ninenik.com/แนะนำการใช้งาน_การเชื่อมต่อ_facebook_ด้วย_php_sdk_v.3.1.1-423.html</link><description><![CDATA[<p>&nbsp;ตัวอย่างโค้ดต่อไปนี้ เป็นแนวทางการเชื่อมต่อกับ facebook ด้วย php sdk&nbsp;</p>
<div>เวอร์ชั่น 3.1.1จะมีไฟล์สำหรับให้โหลด ไปทดสอบตามลิ้งค์ ด้านล่าง</div>
<div>&nbsp;</div>
<div><a target="_blank" href="http://www.ninenik.com/fb/fb3.1.1.rar">http://www.ninenik.com/fb/fb3.1.1.rar</a></div>
<div>&nbsp;</div>
<div>หรือ ดูตัวอย่างก่อนโหลดได้ที่&nbsp;</div>
<div><a target="_blank" href="http://www.ninenik.com/fb/fb3.1.1/test_login.php">http://www.ninenik.com/fb/fb3.1.1/test_login.php</a></div>
<div>&nbsp;</div>
<div>ในเว็บจะมีบทความ ที่เกี่ยวกับ การเชื่อมต่อกับ facebook หลายเนื้อหา แต่บางรายการ</div>
<div>ก็เป็นไปแบบไม่อัพเดท หรือ มีการพัฒนาเพิ่มเติมมาใหม่แล้ว ตัวเก่าอาจจะผิดเพี้ยน หรือใช้งานไม่ได้</div>
<div>หากเพิ่งเริ่มศึกษา แนะนำให้ค้นหาบทความ แล้วดูวันที่ของเนื้อหา และตัวอย่างที่นำมาประกอบ</div>
<div>ก่อนพิจารณาไปนำใช้ใช้งาน</div>
<div>&nbsp;</div>
<div>ส่วนสำหรับแก้ไขจะอยู่ในไฟล์ fb_connect.php</div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;?php
session_start(); // กำหนดไว้ กรณีอาจได้ใช้ตัวแปร session
include(&quot;inc/facebook.php&quot;); //  เรียกใช้งานไฟล์ php-sdk สำหรับ facebook
//
$facebook = new Facebook(array(
  'appId'  =&gt; 'xxxxxx', // appid ที่ได้จาก facebook
  'secret' =&gt; 'xxxxx',  // app secret ที่ได้จาก facebook
  'fileUpload' =&gt; true, // เปิดใช้ในส่วนของการอัพโหลดรูปได้
  'cookie' =&gt; true, // อนุญาตใช้งาน cookie  
));
// สร้างฟังก์ชันไว้สำหรัดทดสอบ การแสดงผลการใช้งาน
function pre($varUse){
	echo &quot;&lt;pre&gt;&quot;;
	print_r($varUse);
	echo &quot;&lt;/pre&gt;&quot;;
}
// Get User ID
$fb_user = $facebook-&gt;getUser();
if($fb_user){
  try{
    // Proceed knowing you have a logged in user who's authenticated.
    $fb_userData=$facebook-&gt;api('/me');
  }catch(FacebookApiException $e) {
    error_log($e);
    $user=null;
  }
}
if(isset($_GET['logout'])){ // ทำการ logout อย่างสมบูรณ์
	$facebook-&gt;destroySession(null); 	// ล่างค่า session ของ facebook
	header(&quot;Location:&quot;.$_SERVER['PHP_SELF']); //ลิ้งค์ไปหน้าที่ต้องการเมื่อ logout เรียบร้อยแล้ว
}
// Login or logout url will be needed depending on current user state.
if($fb_user){
  $logoutUrl = $facebook-&gt;getLogoutUrl(array(
  	&quot;next&quot;=&gt;&quot;http://www.ninenik.com/fb/fb3.1.1/test_login.php?logout&quot;
  ));
} else{
  $loginUrl = $facebook-&gt;getLoginUrl(array(
  	&quot;redirect_uri&quot;=&gt;&quot;http://www.ninenik.com/fb/fb3.1.1/test_login.php&quot;,
	&quot;display&quot;=&gt;&quot;popup&quot;,
	&quot;scope&quot;=&gt;&quot;offline_access,publish_stream,email&quot; // คั่นแต่ละค่าด้วย ,(comma
  ));
}
?&gt;</pre>
<div>&nbsp;</div>]]></description><pubDate>Thu, 13 Oct 2011 16:57:42 +0700</pubDate></item><item><title>การแสดงข้อมูลใน iframe ตามตำแหน่งที่ต้องการด้วย css อย่างง่าย</title><link>http://www.ninenik.com/การแสดงข้อมูลใน_iframe_ตามตำแหน่งที่ต้องการด้วย_css_อย่างง่าย-422.html</link><description><![CDATA[<p>&nbsp;การแสดงข้อมูลใน iframe ตามตำแหน่งที่ต้องการด้วย css อย่างง่าย</p>
<div>&nbsp;</div>
<div>ตัวอย่างโค้ดต่อไปนี้ เป็นแนวทางสำหรับการแสดงผลข้อมูลใน iframe โดยเราสามารถเลือกจะให้</div>
<div>ข้อมูลในส่วนใด ของ iframe แสดงผลตามต้องการ</div>
<div>&nbsp;</div>
<div><strong>โค้ดตัวอย่างทั้งหมด พร้อมตัวอย่าง</strong></div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; 
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;css iframe position&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
body{
	background-color:#FF9;	
}
/* ส่วนกำหนดสำหรับ แสดง iframe  */
div#myiframe_position1{
	position:relative;
	margin:auto;
	display:block;	
	width:270px; /*ความกว้างส่วนของเนื้อหา iframe ที่ต้องการแสดง*/
	height:700px; /* ความสูงส่วนของเนื้อหา iframe ที่ต้องการแสดง */
	overflow:hidden;
}
/* ส่วนกำหนด สำหรับ iframe */
div#myiframe_position1 iframe{
	position:absolute;
	display:block;
	float:left;
	margin-top:-420px; /* ปรับค่าของ iframe ให้ขยับขึ้นบนตามตำแหน่งที่ต้องการ */
	margin-left:-715px; /* ปรับค่าของ iframe ให้ขยับมาด้านซ้ายตามตำแหน่งที่ต้องการ */
}
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;



&lt;div id=&quot;myiframe_position1&quot;&gt;
&lt;iframe src=&quot;http://www.ninenik.com&quot; scrolling=&quot;no&quot;
frameborder=&quot;0&quot; width=&quot;1000&quot; height=&quot;1000&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;


&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>
<div><strong>ตัวอย่าง</strong></div>
<div>&nbsp;</div>
<div>

<style type="text/css">
/* ส่วนกำหนดสำหรับ แสดง iframe  */
div#myiframe_position1{
	position:relative;
	margin:auto;
	display:block;	
	width:270px; /*ความกว้างส่วนของเนื้อหา iframe ที่ต้องการแสดง*/
	height:700px; /* ความสูงส่วนของเนื้อหา iframe ที่ต้องการแสดง */
	overflow:hidden;
}
/* ส่วนกำหนด สำหรับ iframe */
div#myiframe_position1 iframe{
	position:absolute;
	display:block;
	float:left;
	margin-top:-420px; /* ปรับค่าของ iframe ให้ขยับขึ้นบนตามตำแหน่งที่ต้องการ */
	margin-left:-715px; /* ปรับค่าของ iframe ให้ขยับมาด้านซ้ายตามตำแหน่งที่ต้องการ */
}
</style>

<div id="myiframe_position1">
<iframe src="http://www.ninenik.com" scrolling="no"
frameborder="0" width="1000" height="1000"></iframe>
</div>

</div>
<div>&nbsp;</div>
<div><span style="color: rgb(255, 0, 0); "><strong>ส่วนสำคัญ</strong></span> คือ การกำหนดความกว้าง และความสูงของ iframe อย่างน้อยต้องกว้างหรือสูงเท่ากับ</div>
<div>ขอบเขตของเนื้อหาที่ต้องการแสดง ในที่นี้ใช้<span style="color: rgb(255, 0, 0); "> width=&quot;1000&quot; height=&quot;1000&quot; </span>&nbsp;หากกำหนดไม่เหมาะสม</div>
<div>อาจทำให้ข้อมูล iframe ไม่แสดงได้</div>]]></description><pubDate>Tue, 04 Oct 2011 10:39:11 +0700</pubDate></item><item><title>แนวทาง การเลื่อนแล้ว fixed ตำแหน่งเนื้อหาที่ต้องการ ด้วย jQuery</title><link>http://www.ninenik.com/แนวทาง_การเลื่อนแล้ว_fixed_ตำแหน่งเนื้อหาที่ต้องการ_ด้วย_jQuery-421.html</link><description><![CDATA[<p>&nbsp;ตัวอย่างโค้ดต่อไปนี้ เป็นแนวทางสำหรับการสร้างส่วนของเนื้อหาให้สามารถ fixed ตำแหน่ง</p>
<div>เมื่อมีการเลื่อน scrollbar ของหน้าเพจนั้น ถึงตำแหน่งที่เรากำหนด และ ส่วนของเนื้อหานั้น</div>
<div>จะกลับมาอยู่ตำแหน่งเดิม เมื่อการเลื่อน scrollbar หน้าเพจนั้น ไม่เข้าเงื่อนไข</div>
<div>&nbsp;</div>
<div><strong>โค้ดทั้งหมด ดูตัวอย่าง ได้จากล๊งค์ด้านล่าง</strong></div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;fixed position when scroll&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
html,body{
	background-color:#CCC;
	padding:0px;
	margin:0px;	
}
div.main_test{
	position:relative;
	background-color:#999;
	margin:auto;
	width:800px;	
}
div.top_sector{
	position:relative;
	display:block;
	width:100%;
	height:75px;	
	background-color:#036;
	color:#FFF;
}
/* css ส่วนของเนื้อหาที่ต้องการในตรึง เมื่อเลือน scroll ถึงตำแหน่งที่ต้องการ */
div.my_float_div{
	position:relative;
	display:block;
	width:250px;
	height:160px;
	background-color:#DCDCF5;
	color:#000;	
	padding:5px;
}
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;div class=&quot;main_test&quot;&gt;
&lt;div class=&quot;top_sector&quot;&gt;Top Sector&lt;/div&gt;
&lt;br /&gt;
&lt;?php 
// php สร้างบรรทัดใหม่  สำหรับทดสอบ
for($i=1;$i&lt;=10;$i++){ ?&gt;
&lt;?=$i?&gt;.&lt;br /&gt;
&lt;?php } ?&gt;
&lt;div class=&quot;my_float_div&quot;&gt;
Data Content 1&lt;br /&gt;
Data Content 1&lt;br /&gt;
Data Content 1&lt;br /&gt;
Data Content 1&lt;br /&gt;
Data Content 1&lt;br /&gt;
Data Content 1&lt;br /&gt;
Data Content 1&lt;br /&gt;
&lt;/div&gt;
&lt;?php
// php สร้างบรรทัดใหม่  สำหรับทดสอบ
for($i=11;$i&lt;=100;$i++){ ?&gt;
&lt;?=$i?&gt;.&lt;br /&gt;
&lt;?php } ?&gt;

&lt;/div&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
    // เงื่อนไข event เมื่อมีการเลื่อน scrollbar ในหน้าเพจ  
     $(window).scroll(function(){  
//		เมื่อเลื่อน scroll bar หน้าเพจ ถึงตำแหน่งที่มากกว่าหรือเท่ากับตำแหน่งที่ต้องการ
//		เมื่อเลื่อน scroll bar หน้าเพจ ถึงตำแหน่ง ที่ทำให้ div
//		class ชื่อ my_float_div ชิดขอบบนพอดี หาจากคำสั่ง
//		console.log($(document).scrollTop());
         if($(document).scrollTop()&gt;270){ 
			$(&quot;.my_float_div&quot;).css({ /*  */
				'position':'fixed',
				'top':'0px'
			});
         }else{  // เลื่อนกลับมาอยู่ตำแหน่งเดิม ถ้าไม่อยู่ในเงื่อนไข
			$(&quot;.my_float_div&quot;).css({
				'position':'relative'
			});
         }  
     });  	 
});
&lt;/script&gt;


&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><strong>ตัวอย่าง </strong><a target="_blank" href="http://www.ninenik.com/demo/fixed_float_when_scroll.php">http://www.ninenik.com/demo/fixed_float_when_scroll.php</a></div>
<div>&nbsp;</div>
<div>&nbsp;</div>]]></description><pubDate>Thu, 22 Sep 2011 10:42:48 +0700</pubDate></item><item><title>นาฬิกาเวลา จาก server อย่างง่าย </title><link>http://www.ninenik.com/นาฬิกาเวลา_จาก_server_อย่างง่าย_-420.html</link><description><![CDATA[<p>&nbsp;เป็นลูกเล่นสำหรับเอาไปตกแต่งเว็บ เมื่อก่อนเห็นตามเว็บต่างๆ บ่อย แต่เดี๋ยวนี้ไม่ค่อยนิยม หันไปใช้นาฬิกาสวยๆ จาก flash<br />
เอามาแนะนำเผื่อใครสนใจนำไปใช้งาน รูปแบบการทำงาน คือดึงเวลาจาก server เป็นเวลาตั้งต้น จากนั้นเวลาก็จะเดินไปเรื่อย<br />
<br />
ตัวอย่างโค้ดทั้งหมด</p>
<pre name="code" class="php:controls">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;


&lt;div id=&quot;css_time_run&quot;&gt;
&lt;?=date(&quot;H:i:s&quot;)?&gt;
&lt;/div&gt;
&lt;br /&gt;


&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){


	var nowDateTime=new Date(&quot;&lt;?=date(&quot;m/d/Y H:i:s&quot;)?&gt;&quot;);
	var d=nowDateTime.getTime();
	var mkHour,mkMinute,mkSecond;
	 setInterval(function(){
		d=parseInt(d)+1000;
		var nowDateTime=new Date(d);
		mkHour=new String(nowDateTime.getHours());  
		if(mkHour.length==1){  
			mkHour=&quot;0&quot;+mkHour;  
		}
		mkMinute=new String(nowDateTime.getMinutes());  
		if(mkMinute.length==1){  
			mkMinute=&quot;0&quot;+mkMinute;  
		} 		 
		mkSecond=new String(nowDateTime.getSeconds());  
		if(mkSecond.length==1){  
			mkSecond=&quot;0&quot;+mkSecond;  
		} 	
		var runDateTime=mkHour+&quot;:&quot;+mkMinute+&quot;:&quot;+mkSecond;		 
		$(&quot;#css_time_run&quot;).html(runDateTime);	 
	 },1000);


});
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p><style type="text/css">
div#css_time_run{
	font-size:25px;	
}
</style></p>
<p>ตัวอย่าง</p>
<p>&nbsp;</p>
<div id="css_time_run"><!--?=date("H:i:s")?--></div>
<p><br />
<script type="text/javascript">
$(function(){


	var nowDateTime=new Date();
	var d=nowDateTime.getTime();
	var mkHour,mkMinute,mkSecond;
	 setInterval(function(){
		d=parseInt(d)+1000;
		var nowDateTime=new Date(d);
		mkHour=new String(nowDateTime.getHours());  
		if(mkHour.length==1){  
			mkHour="0"+mkHour;  
		}
		mkMinute=new String(nowDateTime.getMinutes());  
		if(mkMinute.length==1){  
			mkMinute="0"+mkMinute;  
		} 		 
		mkSecond=new String(nowDateTime.getSeconds());  
		if(mkSecond.length==1){  
			mkSecond="0"+mkSecond;  
		} 	
		var runDateTime=mkHour+":"+mkMinute+":"+mkSecond;		 
		$("#css_time_run").html(runDateTime);	 
	 },1000);


});
</script></p>]]></description><pubDate>Wed, 07 Sep 2011 16:38:42 +0700</pubDate></item><item><title>ใช้งาน google chart ตัวใหม่สร้าง poll อย่างง่าย</title><link>http://www.ninenik.com/ใช้งาน_google_chart_ตัวใหม่สร้าง_poll_อย่างง่าย-418.html</link><description><![CDATA[<p>&nbsp;อ่านวิธีการใช้งานอย่างโปรได้ด้วยตัวเองที่&nbsp;</p>
<div>&nbsp;</div>
<div><a href="http://code.google.com/apis/chart/interactive/docs/gallery/piechart.html#Data_Format">http://code.google.com/apis/chart/interactive/docs/gallery/piechart.html#Data_Format</a></div>
<div>&nbsp;</div>
<div>โค้ตและตัวอย่างต่อไปนี้ เป็นแนวทางสำหรับรู้จัก และใช้งาน google chart สำหรับสร้าง แผนภูมิ</div>
<div>หรือกราฟ โดยในตัวอย่างจะเป็นการใช้กราฟ ประเภท pie chart หรือวงกลมที่แบ่งสัดส่วนของ</div>
<div>ข้อมูล โดยจะใช้แสดง จำนวนแต่ละประเภทของผลโหวด&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp; ในตัวอย่าง จะใช้วิธีการบันทึกข้อมูลแบบเขียนไฟล์ทับ ข้อมูลเดิม เมื่อมีการโหวด</div>
<div>ส่วนกรณีสำหรับการใช้งานเชื่อมต่อกับฐานข้อมูล สามารถนำไปประยุกต์เพิ่มเติมเองได้</div>
<div>&nbsp;</div>
<div>เนื้อหาจะคล้ายๆ กับ บทความเรื่อง&nbsp;</div>
<div>สร้าง poll แบบสำรวจ ด้วย ajax ใน jQuery อย่างง่าย</div>
<div><a href="http://www.ninenik.com/content.php?arti_id=280">http://www.ninenik.com/content.php?arti_id=280</a></div>
<div>&nbsp;</div>
<div>แต่ในตัวอย่างใหม่จะเขียนโค้ดให้สั้นกว่า และเป็นการใช้งาน google chart เวอร์ชั่นใหม่</div>
<div>&nbsp;</div>
<div>ดาวน์โหดลไฟล์ตัวอย่างได้ที่</div>
<div><a href="http://www.ninenik.com/demo/jquery_poll_google_chart/jquery_poll_google_chart.rar">http://www.ninenik.com/demo/jquery_poll_google_chart/jquery_poll_google_chart.rar</a></div>
<div>&nbsp;</div>
<div>ตัวอย่างการทำงาน</div>
<div><a href="http://www.ninenik.com/demo/jquery_poll_google_chart/jquery_poll_google_chart.php">http://www.ninenik.com/demo/jquery_poll_google_chart/jquery_poll_google_chart.php</a></div>
<div>&nbsp;</div>

<style type="text/css">
#pollDiv{
	display:block;
	padding:10px;
	width:450px;
	border:2px solid #DAC49A;
	background-color:#FDF7EC;	
}
#VotePoll{
	padding:3px 10px;
	background-color:#033;
	border:1px solid #666;
	color:#FFF;
	cursor:pointer;	
}
</style>

<!--Div that will hold the pie chart--> 
    <div id="chart_div"></div> 
 
 
<div id="pollDiv"> 
<strong>&#65279;คุณใช้ภาษาโปรแกรมใด ในการพัฒนาเว็บไซต์
</strong><br><input type="radio" class="css_poll" name="choice" id="radio" value="1" />PHP
<br><input type="radio" class="css_poll" name="choice" id="radio" value="2" />ASP.NET
<br><input type="radio" class="css_poll" name="choice" id="radio" value="3" />ASP
<br><input type="radio" class="css_poll" name="choice" id="radio" value="4" />C#
<br><input type="radio" class="css_poll" name="choice" id="radio" value="5" />Perl
<br><input type="radio" class="css_poll" name="choice" id="radio" value="6" />Python
<br><input type="radio" class="css_poll" name="choice" id="radio" value="7" />อื่นๆ
<br><input type="button" name="VotePoll" id="VotePoll" value="Vote" /> 
</div> 
<script type="text/javascript" src="http://www.google.com/jsapi"></script> 
<script type="text/javascript"> 
google.load("visualization", "1", {packages:["corechart"]});
</script> 
<script type="text/javascript"> 
var drawChart;
$(function(){
	
     function drawChart(voteID,startKey) {
		 $.get("demo/jquery_poll_google_chart/ajax_poll_jquery_google.php",{
			 voteID:voteID,
			startKey:startKey 
		 },function(data){
 
			var resultData=eval('[' + data + ']');
			var data = new google.visualization.DataTable();
			data.addColumn('string', 'Choice Text');
			data.addColumn('number', 'Choice Vote Value');
			data.addRows(resultData);		
	
			var chart = new google.visualization.PieChart($("#pollDiv")[0]);
			chart.draw(data, 
			{
				width: 450, height: 300, title: 'คุณใช้ภาษาโปรแกรมใด ในการพัฒนาเว็บไซต์'
			});			 
		 });
 
      }
	  	
 
	$("#VotePoll").click(function(){
		var chooseKey="";
		var startKey=$(".css_poll").size()+1;
		if($(".css_poll:checked").size()>0){ // 
			checkCondi=1;
			chooseKey=$(".css_poll:checked").val();
			drawChart(chooseKey,startKey);
		}else{
			alert("กรุณาเลือกรายการ");
		}
		
	});
});
</script> ]]></description><pubDate>Wed, 03 Aug 2011 16:47:48 +0700</pubDate></item><item><title>แทรก +1 button ในเว็บจาก google plus</title><link>http://www.ninenik.com/แทรก_+1_button_ในเว็บจาก_google_plus-417.html</link><description><![CDATA[<p>เห็นหลายๆเว็บไซต์ เขาใส่ +1 button ในเว็บกันแล้ว อยากจะเอามาใส่ในเว็บ ninenik.com บ้าง<br />
<br />
เข้าไปอ่าน และปรับแต่งค่าต่างๆ แล้วเอาไปใส่เว็บได้เลยอย่างง่ายดายได้ที่<br />
<a href="http:// http://www.google.com/intl/en/webmasters/+1/button/index.html" target="_blank"><br />
http://www.google.com/intl/en/webmasters/+1/button/index.html</a><br />
<br />
Javascript Code แทรกไว้ก่อนแท็กปิด body หรือในแท็ก head<br />
<br />
&nbsp;</p>
<pre name="code" class="javascript:controls">
&lt;!-- Place this tag in your head or just before your close body tag --&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;https://apis.google.com/js/plusone.js&quot;&gt;
  {lang: 'th'} // สำหรับปรับแต่งภาษาไทย อังกฤษก็เปลี่ยนเป็น en
&lt;/script&gt;</pre>
<p><br />
<br />
Code ที่ต้องการแสดงปุ่ม +1 ไว้ตรงตำแหน่งที่ต้องการให้แสดง<br />
<br />
&nbsp;</p>
<pre name="code" class="php:controls">
&lt;!-- Place this tag where you want the +1 button to render --&gt;
&lt;g:plusone size=&quot;small&quot; callback=&quot;alert('OK man');&quot; href=&quot;http://www.ninenik.com&quot;&gt;&lt;/g:plusone&gt;</pre>
<p><br />
<br />
<strong>attrbute ภายในสำหรับปรับแต่ง</strong><br />
<strong>attrbute size ตอนนี้มี 4 แบบ </strong><br />
&nbsp;- small ขนาด 15px<br />
&nbsp;- medium ขนาด 20px<br />
&nbsp;- standard ขนาด 24px โดยที่หากใช้ขนาด standard ก็ไม่ต้องกำหนด attribute size<br />
&nbsp;- Tall ขนาด 60px<br />
<strong><br />
attribute callback</strong><br />
&nbsp;ใช้กำหนดสำหรับเรียกใช้ฟังก์ชัน javascript หลังจากคลิกที่ปุ่ม +1 แล้ว ว่าต้องการให้ทำอะไรเช่น<br />
&nbsp;&nbsp; callback=&quot;alert('OK man');&quot;&nbsp; หลังจากคลิกแล้วให้ขึ้น alert ว่า OK man<br />
<strong><br />
attribute count</strong><br />
&nbsp;ใช้กำหนดหากต้องการให้แสดงจำนวนคนที่กด +1 กี่คน หรือไม่<br />
&nbsp;count=&quot;false&quot;&nbsp; ไม่แสดง<br />
&nbsp;กรณีต้องการแสดง ไม่ต้องแทรก attribute count<br />
<br />
<strong>attribue href</strong><br />
&nbsp;ใช้กำหนด url ของหน้าเพจนั้นๆ จะกำหนดหรือไม่ ก็ได้ หากไม่กำหนด ก็จะใช้ url ของเพจนั้นเป็นหลัก <br />
<br />
<br />
อ่านรายละะอียดแบบเจาะลืก อย่างโปรได้ที่<br />
<br />
<a href="http://code.google.com/apis/+1button/" target="_blank">http://code.google.com/apis/+1button/</a></p>]]></description><pubDate>Sat, 16 Jul 2011 16:21:09 +0700</pubDate></item><item><title>ลูกเล่น เพิ่มช่องรับ input type file อัตโนมัติ ด้วย jQuery</title><link>http://www.ninenik.com/ลูกเล่น_เพิ่มช่องรับ_input_type_file_อัตโนมัติ_ด้วย_jQuery-416.html</link><description><![CDATA[<p>&nbsp;ตัวอย่างต่อไปนี้ เป็นแนวทางสำหรับนำไปใช้ในการ ให้สามารถอัพโหลดไฟล์ ได้หลายๆ ไฟล์พร้อมกัน</p>
<div>ในที่นี่ ใช้กับการอัพโหลดรูปภาพ โดยจะมีฟังก์ชั่น ในการอัพโหลด มาในตัวอย่างด้วย</div>
<div>หลักการคือ เมื่อเราเลือกไฟล์ หนึ่งแล้ว เราจะสามารถเลือกไฟล์ที่ต้องการอัพโหลด เพิ่มขึ้นมาเรื่อยๆ</div>
<div>รวมทั้งยังสามารถยกเลิก หรือลบไฟล์ที่ได้ทำการเลือกไปแล้วออก ก่อนทำการอัพโหลด</div>
<div>&nbsp;</div>
<div>โค้ดตัวอย่างเฉพาะในส่วนของ jQuery&nbsp;</div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;div style=&quot;margin:auto;width:800px;&quot;&gt;
&lt;form action=&quot;&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; name=&quot;form1&quot; id=&quot;form1&quot;&gt;
  &lt;table width=&quot;500&quot; border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;0&quot;&gt;
    &lt;tr class=&quot;css_row_upload&quot;&gt;
      &lt;td width=&quot;150&quot; align=&quot;right&quot; bgcolor=&quot;#ECECEC&quot;&gt;Picture:: &amp;nbsp;&lt;/td&gt;
      &lt;td bgcolor=&quot;#ECECEC&quot;&gt;
      &lt;input type=&quot;file&quot; name=&quot;pic_upload[]&quot; class=&quot;css_pic_upload&quot; id=&quot;pic_upload[]&quot; 
      onpropertychange=&quot;if(window.event.propertyName=='value'){$(this).blur();};&quot; /&gt;
        
        &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;br /&gt;
&lt;br /&gt;
    &lt;input type=&quot;submit&quot; name=&quot;upPic&quot; id=&quot;upPic&quot; value=&quot;UPLOAD NOW&quot; /&gt;

&lt;/form&gt;

&lt;hr /&gt;

&lt;/div&gt;


&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
	
	var empty_upload='\
    &lt;tr class=&quot;css_row_upload&quot;&gt;\
      &lt;td width=&quot;150&quot; align=&quot;right&quot; bgcolor=&quot;#ECECEC&quot;&gt;Picture:: &amp;nbsp;&lt;/td&gt;\
      &lt;td bgcolor=&quot;#ECECEC&quot;&gt;\
      &lt;input type=&quot;file&quot; name=&quot;pic_upload[]&quot; class=&quot;css_pic_upload&quot;\
	  id=&quot;pic_upload[]&quot; onpropertychange=&quot;if(window.event.propertyName==\'value\'){$(this).blur();};&quot; /&gt;\
        &lt;a href=&quot;#&quot; class=&quot;css_remove_fileupload&quot;&gt;Remove&lt;/a&gt;\
        &lt;/td&gt;\
    &lt;/tr&gt;\
	';


	$(&quot;.css_pic_upload&quot;).live(&quot;change onpropertychange&quot;,function(){
		var file_value=$(this).val();
		console.log(file_value);
		if(file_value!=&quot;&quot;){		
			$(this).parents(&quot;tr.css_row_upload&quot;).after(empty_upload);
		}
	});

	$(&quot;.css_remove_fileupload&quot;).live(&quot;click&quot;,function(e){
		e.preventDefault();
		$(this).parents(&quot;tr.css_row_upload&quot;).remove();		
	});	
});

&lt;/script&gt;</pre>
<div>ตัวอย่าง</div>
<div>&nbsp;</div>
<div>
<div style="margin:auto;width:800px;">
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <table width="500" border="0" cellspacing="2" cellpadding="0">
        <tbody>
            <tr class="css_row_upload">
                <td width="150" align="right" bgcolor="#ECECEC">Picture:: &nbsp;</td>
                <td bgcolor="#ECECEC"><input type="file" name="pic_upload[]" class="css_pic_upload" id="pic_upload[]" onpropertychange="if(window.event.propertyName=='value'){$(this).blur();};" /></td>
            </tr>
        </tbody>
    </table>
    <br />
    <br />
    <input type="submit" name="upPic" id="upPic" value="UPLOAD NOW" />
</form>
<hr />
</div>
<script type="text/javascript">
$(function(){
	
	var empty_upload='\
    <tr class="css_row_upload">\
      <td width="150" align="right" bgcolor="#ECECEC">Picture:: &nbsp;</td>\
      <td bgcolor="#ECECEC">\
      <input type="file" name="pic_upload[]" class="css_pic_upload"\
	  id="pic_upload[]" onpropertychange="if(window.event.propertyName==\'value\'){$(this).blur();};" />\
        <a href="#" class="css_remove_fileupload">Remove</a>\
        </td>\
    </tr>\
	';


	$(".css_pic_upload").live("change onpropertychange",function(){
		var file_value=$(this).val();
		console.log(file_value);
		if(file_value!=""){		
			$(this).parents("tr.css_row_upload").after(empty_upload);
		}
	});

	$(".css_remove_fileupload").live("click",function(e){
		e.preventDefault();
		$(this).parents("tr.css_row_upload").remove();		
	});	
});

</script></div>
<div>&nbsp;</div>
<div>โค้ดตัวอย่างทั้งหมด</div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
 &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;&lt;/title&gt;



&lt;/head&gt;

&lt;body&gt;


&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;

&lt;div style=&quot;margin:auto;width:800px;&quot;&gt;
&lt;form action=&quot;&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; name=&quot;form1&quot; id=&quot;form1&quot;&gt;
  &lt;table width=&quot;500&quot; border=&quot;0&quot; cellspacing=&quot;2&quot; cellpadding=&quot;0&quot;&gt;
    &lt;tr class=&quot;css_row_upload&quot;&gt;
      &lt;td width=&quot;150&quot; align=&quot;right&quot; bgcolor=&quot;#ECECEC&quot;&gt;Picture:: &amp;nbsp;&lt;/td&gt;
      &lt;td bgcolor=&quot;#ECECEC&quot;&gt;
      &lt;input type=&quot;file&quot; name=&quot;pic_upload[]&quot; class=&quot;css_pic_upload&quot; id=&quot;pic_upload[]&quot; 
      onpropertychange=&quot;if(window.event.propertyName=='value'){$(this).blur();};&quot; /&gt;
        
        &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;br /&gt;
&lt;br /&gt;
    &lt;input type=&quot;submit&quot; name=&quot;upPic&quot; id=&quot;upPic&quot; value=&quot;UPLOAD NOW&quot; /&gt;

&lt;/form&gt;

&lt;hr /&gt;

&lt;/div&gt;

&lt;?php

function multiupload($img,$imglocate,$key){
	$allowed_types=array('jpg','jpeg','gif','png','swf');   
	if($img['name'][$key]!=''){
		$fileupload1=$img['tmp_name'][$key];
		$g_img=explode(&quot;.&quot;,$img['name'][$key]);
		$ext = strtolower(array_pop($g_img));  
		$file_up=time().&quot;-&quot;.$key.&quot;.&quot;.$ext;
		echo $file_up;
		if($fileupload1!=&quot;&quot; &amp;&amp; in_array($ext,$allowed_types)){
				copy($fileupload1,$imglocate.$file_up);	
				chmod($imglocate.$file_up,0777);				
		}				
	}
	return $file_up; // ส่งกลับชื่อไฟล์
}

if(isset($_POST['upPic'])){
	$multiupload_pic=$_FILES['pic_upload'];
	$arr_multiupload_pic=$multiupload_pic['name'];
	if(count($arr_multiupload_pic)&gt;0){
		foreach($arr_multiupload_pic as $key=&gt;$value){
			$file_to_up=multiupload($multiupload_pic,&quot;tmp_pic/&quot;,$key);
			if($file_to_up!=&quot;&quot;){
				echo &quot;$file_to_up&lt;br&gt;&quot;;
				//  นำตัวแปรชื่อไฟล์ไปบันทึกลงฐานข้อมูล หรืออื่นๆ
				
			}
		}		
	}
	
}

?&gt;


&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
	
	var empty_upload='\
    &lt;tr class=&quot;css_row_upload&quot;&gt;\
      &lt;td width=&quot;150&quot; align=&quot;right&quot; bgcolor=&quot;#ECECEC&quot;&gt;Picture:: &amp;nbsp;&lt;/td&gt;\
      &lt;td bgcolor=&quot;#ECECEC&quot;&gt;\
      &lt;input type=&quot;file&quot; name=&quot;pic_upload[]&quot; class=&quot;css_pic_upload&quot;\
	  id=&quot;pic_upload[]&quot; onpropertychange=&quot;if(window.event.propertyName==\'value\'){$(this).blur();};&quot; /&gt;\
        &lt;a href=&quot;#&quot; class=&quot;css_remove_fileupload&quot;&gt;Remove&lt;/a&gt;\
        &lt;/td&gt;\
    &lt;/tr&gt;\
	';


	$(&quot;.css_pic_upload&quot;).live(&quot;change onpropertychange&quot;,function(){
		var file_value=$(this).val();
		console.log(file_value);
		if(file_value!=&quot;&quot;){		
			$(this).parents(&quot;tr.css_row_upload&quot;).after(empty_upload);
		}
	});

	$(&quot;.css_remove_fileupload&quot;).live(&quot;click&quot;,function(e){
		e.preventDefault();
		$(this).parents(&quot;tr.css_row_upload&quot;).remove();		
	});	
});

&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>]]></description><pubDate>Mon, 27 Jun 2011 09:36:23 +0700</pubDate></item><item><title>แก้ปัญหา event onchange ของ input type file ไม่ทำงานทันทีใน ใน IE</title><link>http://www.ninenik.com/แก้ปัญหา_event_onchange_ของ_input_type_file_ไม่ทำงานทันทีใน_ใน_IE-415.html</link><description><![CDATA[<p>&nbsp;event onchange ของ input type file ใน IE เมื่อมีการเลือกไฟล์ที่ต้องการอัพโหลด จะไม่ทำงาน</p>
<div>ทันที ต้องคลิกที่ว่างหรือ focus ออกจาก input type file ก่อน คำสั่งใน event onchange จึงจะทำงาน</div>
<div>แต่กับ บราวเซอร์อื่นๆ จะไม่เจอปัญหานี้&nbsp;</div>
<div>&nbsp;</div>
<div>วิธีการในการแก้ไขคือ ให้ แทรก attribute ชื่อ onpropertychange เข้าไปใน input type file ที่ต้องการ</div>
<div>ให้ทำงานทันทีเมื่อคลิกเลือกไฟล์</div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
onpropertychange=&quot;if(window.event.propertyName=='value'){$(this).blur();};&quot;</pre>
<div>&nbsp;</div>
<div>ตัวอย่าง</div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;input type=&quot;file&quot; name=&quot;pic_upload2&quot; class=&quot;css_pic_upload2&quot; id=&quot;pic_upload2&quot;  /&gt;</pre>
<div>&nbsp;</div>
<div>เมื่อแทรกแล้ว จะได้เป็น</div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;input type=&quot;file&quot; name=&quot;pic_upload2&quot; class=&quot;css_pic_upload2&quot; id=&quot;pic_upload2&quot; 
onpropertychange=&quot;if(window.event.propertyName=='value'){$(this).blur();};&quot;   /&gt;</pre>
<div>&nbsp;</div>
<div>
<div>ตัวอย่างทดสอบ (ให้ทำการทดสอบรันใน IE จึงจะสามารถเข้าใจผลลัพธ์ได้)</div>
<div>&nbsp;</div>
<div>ให้ทดสอบโดลการเลือก ไฟล์ใน input type file ตัวที่สองก่อน โดยหลังจากเลือกไฟล์ จะพบว่ามีการ</div>
<div>alert ค่าทันที เนื่องจากเราใช้วิธีการแก้ปัญหาตามคำแนะนำข้างต้น</div>
<div>&nbsp;</div>
<div>จากนั้น ให้ลองเลือกไฟล์ ใน input type file ตัวแรก โดยหลังเลือกไฟล์ และไม่ได้คลิกที่ว่าง หรือที่อื่นใด</div>
<div>คำสั่ง alert จะไม่ทำงาน จนกระทั้งเรา คลิกที่ว่าง หรือที่อื่นใด คำสั่ง alert จึงจะทำงาน</div>
<div>&nbsp;</div>
<div style="margin:auto;width:800px;">
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">

<input type="file" name="pic_upload" class="css_pic_upload" id="pic_upload"   />

<br />
<br />

<input type="file" name="pic_upload2" class="css_pic_upload2" id="pic_upload2" 
onpropertychange="if(window.event.propertyName=='value'){$(this).blur();};"   />

</form>

<hr />

</div>
<script type="text/javascript">
$(function(){
	
	$(".css_pic_upload").live("change",function(){
		var file_value=$(this).val();
		alert(file_value);
	});


	$(".css_pic_upload2").live("change",function(){
		var file_value=$(this).val();
		alert(file_value);
	});

});
</script>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
</div>
<div>&nbsp;</div>
<div>ตัวอย่างโค้ดทดสอบทั้งหมด</div>
<div>&nbsp;</div>
<pre name="code" class="php:controls">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; 
&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;title&gt;&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

&lt;!--
onpropertychange=&quot;if(window.event.propertyName=='value'){$(this).blur();};&quot;

--&gt;
&lt;div style=&quot;margin:auto;width:800px;&quot;&gt;
&lt;form action=&quot;&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; name=&quot;form1&quot; id=&quot;form1&quot;&gt;

&lt;input type=&quot;file&quot; name=&quot;pic_upload&quot; class=&quot;css_pic_upload&quot; id=&quot;pic_upload&quot;   /&gt;

&lt;br /&gt;
&lt;br /&gt;

&lt;input type=&quot;file&quot; name=&quot;pic_upload2&quot; class=&quot;css_pic_upload2&quot; id=&quot;pic_upload2&quot; 
onpropertychange=&quot;if(window.event.propertyName=='value'){$(this).blur();};&quot;   /&gt;

&lt;/form&gt;

&lt;hr /&gt;

&lt;/div&gt;

&lt;script type=&quot;text/javascript&quot; src=&quot;http://code.jquery.com/jquery-latest.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(function(){
	
	$(&quot;.css_pic_upload&quot;).live(&quot;change&quot;,function(){
		var file_value=$(this).val();
		alert(file_value);
	});


	$(&quot;.css_pic_upload2&quot;).live(&quot;change&quot;,function(){
		var file_value=$(this).val();
		alert(file_value);
	});

});
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div>&nbsp;</div>]]></description><pubDate>Fri, 24 Jun 2011 15:52:56 +0700</pubDate></item></channel></rss>
