<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>KomKid.Net &#187; JavaScript</title>
	<atom:link href="http://www.komkid.net/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.komkid.net</link>
	<description>คิดแตกต่าง แต่ไม่แตกแยก คิดแปลก แตกต่างอย่างมีเหตุผล</description>
	<lastBuildDate>Thu, 18 Feb 2010 01:46:59 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JavaScript : 1 Form 2 Target</title>
		<link>http://www.komkid.net/2010/01/javascript-1-form-2-target/</link>
		<comments>http://www.komkid.net/2010/01/javascript-1-form-2-target/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 14:48:32 +0000</pubDate>
		<dc:creator>Komkid</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.komkid.net/?p=742</guid>
		<description><![CDATA[12345678910111213141516171819202122&#160; &#160; &#160; &#160; &#60;script type=&#34;text/javascript&#34;&#62;
&#160; &#160; &#160; &#160; &#160;&#60;!--
&#160; &#160; &#160; &#160; &#160;function submitView&#40;&#41;
&#160; &#160; &#160; &#160; &#160;&#123;
&#160; &#160; &#160; &#160; &#160; &#160;myform = document.form1;
&#160; &#160; &#160; &#160; &#160; &#160;myform.target=&#34;_blank&#34;;
&#160; &#160; &#160; &#160; &#160; &#160;myform.action=&#34;view.php&#34;;
&#160; &#160; &#160; &#160; &#160; &#160;myform.submit&#40;&#41;;
&#160; &#160; &#160; &#160; &#160; &#160;return false;
&#160; &#160; &#160; &#160; &#160;&#125;
&#160; &#160; &#160; &#160; &#160;
&#160; [...]]]></description>
		<wfw:commentRss>http://www.komkid.net/2010/01/javascript-1-form-2-target/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript : AJAX for Province, Amphur, Tumbol</title>
		<link>http://www.komkid.net/2009/12/javascript-ajax-for-province-amphur-tumbol/</link>
		<comments>http://www.komkid.net/2009/12/javascript-ajax-for-province-amphur-tumbol/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 16:13:58 +0000</pubDate>
		<dc:creator>Komkid</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.komkid.net/?p=312</guid>
		<description><![CDATA[เริ่มจาก ได้ฐานข้อมูล จังหวัด -> อำเภอ -> ตำบล ที่ดีมาก มาจากไหน ตั้งแต่เมื่อไหร่ ไม่รู้ แต่พอจะใช้ขึ้นมา เพิ่งพบว่า ที่ได้มานั้นมันดีจริง ๆ ดียังไง ให้เปิด ตรวจสอบหมายเลขบัตรประจำตัวประชาชน ประกอบครับ (ที่จริงต้องเปิด http://th.wikipedia.org/wiki/เลขประจำตัวประชาชนไทย ด้วย)
มาดูฐานข้อมูลกันก่อน
1.จังหวัด
ตารางเป็นแบบนี้

ข้อมูลเป็นแบบนี้

สังเกตดูนะครับ id มันคือ หลักที่ 2+3 ของเลขบัตรประจำตัวประชาชน
2.อำเภอ
ตารางเป็นแบบนี้

ข้อมูลเป็นแบบนี้

id ของตารางนี้ ก็คือ หลักที่ 4+5 ของเลขบัตรประจำตัวประชาชน
3.ตำบล
ตารางเป็นแบบนี้

ข้อมูลเป็นแบบนี้

อันนี้ หลักที่ 6-10 ค่อนข้างกว้าง จึงระบุไม่ได้ แต่ได้ 2 อันแรกก็ดูดีแล้วน่ะ
AJAX กับ PHP ก็ต้องเริ่มจาก
1.เตรียมการสำหรับ form
12345678910111213141516171819202122232425&#160; &#160; $ProvinceSelect.=&#34;&#60;select name='ProvinceId' &#160;onClick='javascript:getAmphur(this.value);'&#62;&#34;;
&#160; &#160; $SQL=&#34;SELECT id,name FROM sci._province ORDER BY id&#34;;
&#160; [...]]]></description>
		<wfw:commentRss>http://www.komkid.net/2009/12/javascript-ajax-for-province-amphur-tumbol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript : ตรวจสอบหมายเลขบัตรประจำตัวประชาชน</title>
		<link>http://www.komkid.net/2009/08/javascript-validate-thai-citizen-id/</link>
		<comments>http://www.komkid.net/2009/08/javascript-validate-thai-citizen-id/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 09:41:46 +0000</pubDate>
		<dc:creator>Komkid</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.komkid.net/?p=307</guid>
		<description><![CDATA[12345678910111213141516171819202122function checkID&#40;id&#41; &#123;
//ตรวจว่าป้อนถูกตามรูปแบบที่กำหนดมั้ย x-xxxx-xxxxx-xx-x
&#160; &#160; var regExpObj = /^\d{1}\-\d{1,4}\-\d{1,5}\-\d{1,2}\-\d{1}$/;
&#160; &#160; if &#40;regExpObj.test&#40;id&#41; == false&#41; return false;

//ตัด - เอาแต่เลขมาตรวจ
&#160; &#160; id = id.replace&#40;/-/g,&#34;&#34;&#41;;
//ตรวจว่ามี 13 หลักถูกมั้ย
&#160; &#160; if &#40;id.length!=13&#41; return false;
//เลขนำหน้าของมีได้แค่ 1-8 
&#160; &#160; if&#40; id.charAt&#40;0&#41; &#60; 1 &#124;&#124; id.charAt&#40;0&#41; &#62; 8 &#41; return false;
&#160; &#160; 
//คำนวณหลักสุดท้าย
&#160; &#160; for&#40;i=0,sum=0;i&#60;12;i++&#41;
&#160; &#160; &#160; &#160; sum += parseInt&#40;id.charAt&#40;i&#41;&#41;*&#40;13-i&#41;;
&#160; &#160; sum [...]]]></description>
		<wfw:commentRss>http://www.komkid.net/2009/08/javascript-validate-thai-citizen-id/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript : set, get and delete cookie</title>
		<link>http://www.komkid.net/2009/08/javascript-set-get-and-delete-cookie/</link>
		<comments>http://www.komkid.net/2009/08/javascript-set-get-and-delete-cookie/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 21:20:15 +0000</pubDate>
		<dc:creator>Komkid</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[กันลืม]]></category>

		<guid isPermaLink="false">http://www.komkid.net/?p=311</guid>
		<description><![CDATA[12345678910111213141516171819202122232425262728function getCookie&#40;c_name&#41;
&#123;
if &#40;document.cookie.length&#62;0&#41;
&#160; &#123;
&#160; c_start=document.cookie.indexOf&#40;c_name + &#34;=&#34;&#41;;
&#160; if &#40;c_start!=-1&#41;
&#160; &#160; &#123; 
&#160; &#160; c_start=c_start + c_name.length+1; 
&#160; &#160; c_end=document.cookie.indexOf&#40;&#34;;&#34;,c_start&#41;;
&#160; &#160; if &#40;c_end==-1&#41; c_end=document.cookie.length;
&#160; &#160; return unescape&#40;document.cookie.substring&#40;c_start,c_end&#41;&#41;;
&#160; &#160; &#125; 
&#160; &#125;
return &#34;&#34;;
&#125;

function setCookie&#40;c_name,value,expiredays&#41;
&#123;
var exdate=new Date&#40;&#41;;
exdate.setDate&#40;exdate.getDate&#40;&#41;+expiredays&#41;;
document.cookie=c_name+ &#34;=&#34; +escape&#40;value&#41;+
&#40;&#40;expiredays==null&#41; ? &#34;&#34; : &#34;;expires=&#34;+exdate.toGMTString&#40;&#41;&#41;;
&#125;

function deleteCookie&#40; name, path, domain &#41; &#123;
if &#40; Get_Cookie&#40; name &#41; &#41; document.cookie = name + [...]]]></description>
		<wfw:commentRss>http://www.komkid.net/2009/08/javascript-set-get-and-delete-cookie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript : GET variable from query string</title>
		<link>http://www.komkid.net/2009/08/javascript-get-variable-from-query-string/</link>
		<comments>http://www.komkid.net/2009/08/javascript-get-variable-from-query-string/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 21:12:54 +0000</pubDate>
		<dc:creator>Komkid</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[กันลืม]]></category>

		<guid isPermaLink="false">http://www.komkid.net/?p=310</guid>
		<description><![CDATA[12fullURL = parent.document.URL
GetVar = fullURL.substring&#40;fullURL.indexOf&#40;'?'&#41;+xxx, fullURL.length&#41;
? = variable name
xxx = length of GET variable name.
Example.
12fullURL = parent.document.URL
GetVar = fullURL.substring&#40;fullURL.indexOf&#40;'topicid'&#41;+7, fullURL.length&#41;
]]></description>
		<wfw:commentRss>http://www.komkid.net/2009/08/javascript-get-variable-from-query-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript : Get current year</title>
		<link>http://www.komkid.net/2009/08/javascript-get-current-year/</link>
		<comments>http://www.komkid.net/2009/08/javascript-get-current-year/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 21:08:29 +0000</pubDate>
		<dc:creator>Komkid</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[กันลืม]]></category>

		<guid isPermaLink="false">http://www.komkid.net/?p=309</guid>
		<description><![CDATA[12345var today = new Date&#40;&#41;;
ThisYear = today.getYear&#40;&#41;+0;
if&#40;ThisYear &#60;= 1999&#41;&#123;
&#160; &#160; &#160;ThisYear = ThisYear - 100 + 2000;
&#125;
]]></description>
		<wfw:commentRss>http://www.komkid.net/2009/08/javascript-get-current-year/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript : Validate for empty input</title>
		<link>http://www.komkid.net/2009/08/javascript-validate-for-empty-input/</link>
		<comments>http://www.komkid.net/2009/08/javascript-validate-for-empty-input/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 21:04:11 +0000</pubDate>
		<dc:creator>Komkid</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[กันลืม]]></category>

		<guid isPermaLink="false">http://www.komkid.net/?p=308</guid>
		<description><![CDATA[Don&#8217;t :
1if &#40;form.input.value == &#34;&#34;&#41;
Do :
1if &#40;form.input.value.length == 0&#41;
or
1if &#40;form.input.value.replace&#40;/\s+$/, &#34;&#34;&#41; == &#34;&#34;&#41;
]]></description>
		<wfw:commentRss>http://www.komkid.net/2009/08/javascript-validate-for-empty-input/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript : Form focus on load</title>
		<link>http://www.komkid.net/2009/08/javascript-form-focus-on-load/</link>
		<comments>http://www.komkid.net/2009/08/javascript-form-focus-on-load/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 21:01:46 +0000</pubDate>
		<dc:creator>Komkid</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[กันลืม]]></category>

		<guid isPermaLink="false">http://www.komkid.net/?p=306</guid>
		<description><![CDATA[1234567891011121314151617181920212223242526272829/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Lee Underwood &#124; http://javascript.internet.com/ */

function getFocus&#40;&#41; &#123;
&#160; // place the id below of the field you want to have focus upon page load
&#160; var focusHere = document.getElementById&#40;&#34;yourName&#34;&#41;;
&#160; focusHere = focusHere.focus&#40;&#41;;
&#125;

// Multiple onload function created by: Simon Willison
// http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent&#40;func&#41; &#123;
&#160; [...]]]></description>
		<wfw:commentRss>http://www.komkid.net/2009/08/javascript-form-focus-on-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
