<?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>jQueryTips by Tee++; &#187; Plugins</title>
	<atom:link href="http://www.jquerytips.com/category/plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jquerytips.com</link>
	<description>Coding is fun.</description>
	<lastBuildDate>Sun, 25 Apr 2010 11:30:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery Validation ครบทุกเม็ดในการ validate</title>
		<link>http://www.jquerytips.com/2009/04/30/jquery-validation-plugin/</link>
		<comments>http://www.jquerytips.com/2009/04/30/jquery-validation-plugin/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 18:05:25 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=407</guid>
		<description><![CDATA[ใจจริงนั้น วันนี้ขี้เกียจอัพเดทมากๆ แต่นี่ก็ใกล้จะหมดเดือน เมษาแล้ว และถ้าอัพบทความนี้สำเร็จ ก็จะกลายเป็นเดือน ที่มีบทความอัพเดทมากที่สุด นั่นก็คือ &#8220;11 บทความ&#8221; เรียกว่าเป็นการทำลายสถิติ ตัวเอง นั่นเอง 555+
นานมาแล้วครั้งนึงผมเคยแนะนำ plugin ของ jQuery ที่ชื่อว่า Really Simple Validation ซึ่งก็เอาไว้ใช้ทำงาน validate ข้อมูลจาก Form เป็นตัวที่ค่อนข้างจะใช้งานง่ายมากเลยทีเดียว 
แต่ในชีวิตจริงผมไม่ค่อยจะใช้ตัวนั้นหรอกครับ ตัวที่ผมใช้มันคือ ตัวนี้ครับ แต่ด้วยความที่มัน ฉลาดและมากความสามารถ แน่นอน มันต้องทำให้ผมเหนื่อยในการที่จะ่ายทอดออกมาแน่ๆ เลยเพิ่งจะมาขยันเอาตอนนี้แหละครับ 
สำหรับ validation plugin ตัวนี้นั้น สามารถที่จะ ตรวจเช็ค ข้อมูลได้หลาย แบบมากๆ เรียกว่าทุกแบบเลยดีกว่า เพราะมันเขียน condition เติมเองได้ รวมไปถึงการ remote เพื่อใช้ตรวจสอบ พวกชื่อ username, email, captcha ได้โดยไม่ต้อง มีการเปลี่ยน [...]]]></description>
			<content:encoded><![CDATA[<p>ใจจริงนั้น วันนี้ขี้เกียจอัพเดทมากๆ แต่นี่ก็ใกล้จะหมดเดือน เมษาแล้ว และถ้าอัพบทความนี้สำเร็จ ก็จะกลายเป็นเดือน ที่มีบทความอัพเดทมากที่สุด นั่นก็คือ &#8220;11 บทความ&#8221; เรียกว่าเป็นการทำลายสถิติ ตัวเอง นั่นเอง 555+</p>
<p>นานมาแล้วครั้งนึงผมเคยแนะนำ plugin ของ jQuery ที่ชื่อว่า <a href="http://www.jquerytips.com/2008/11/21/really-simple-validation/">Really Simple Validation</a> ซึ่งก็เอาไว้ใช้ทำงาน validate ข้อมูลจาก Form เป็นตัวที่ค่อนข้างจะใช้งานง่ายมากเลยทีเดียว </p>
<p>แต่ในชีวิตจริงผมไม่ค่อยจะใช้ตัวนั้นหรอกครับ ตัวที่ผมใช้มันคือ <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">ตัวนี้ครับ</a> แต่ด้วยความที่มัน ฉลาดและมากความสามารถ แน่นอน มันต้องทำให้ผมเหนื่อยในการที่จะ่ายทอดออกมาแน่ๆ เลยเพิ่งจะมาขยันเอาตอนนี้แหละครับ </p>
<p>สำหรับ validation plugin ตัวนี้นั้น สามารถที่จะ ตรวจเช็ค ข้อมูลได้หลาย แบบมากๆ เรียกว่าทุกแบบเลยดีกว่า เพราะมันเขียน condition เติมเองได้ รวมไปถึงการ remote เพื่อใช้ตรวจสอบ พวกชื่อ username, email, captcha ได้โดยไม่ต้อง มีการเปลี่ยน page แต่อย่างใด <span id="more-407"></span></p>
<p>ทั้งยัง config การแสดง valid, invalid ข้อความ ได้อย่างสวยงาม แต่ว่า ผมคงไม่อธิบายหมดหรอก มันเยอะจัดเลย เหนื่อยนะ เอาแค่พอใช้งาน ได้ไปศึกษาต่อได้ก็พอแล้วล่ะ มาเริ่มกันเลยดีกว่า เริ่มจะง่วงนิดๆ ละ&#8230;</p>
<p><strong>Head:</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;script src=<span class="st0">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;script src=<span class="st0">&quot;jquery.validate.js&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&#8216;#demo&#8217;</span><span class="br0">&#41;</span>.<span class="me1">validate</span><span class="br0">&#40;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rules: <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">name</span>: <span class="st0">&quot;required&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; gender: <span class="st0">&quot;required&quot;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; errorPlacement: <span class="kw2">function</span><span class="br0">&#40;</span>error, element<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span>element.<span class="kw1">is</span><span class="br0">&#40;</span><span class="st0">&#8216;:radio&#8217;</span><span class="br0">&#41;</span> || element.<span class="kw1">is</span><span class="br0">&#40;</span><span class="st0">&#8216;:checkbox&#8217;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span class="me1">appendTo</span><span class="br0">&#40;</span> element.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">next</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">else</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error.<span class="me1">appendTo</span><span class="br0">&#40;</span> element.<span class="me1">parent</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">next</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success: <span class="kw2">function</span><span class="br0">&#40;</span>label<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; label.<span class="me1">html</span><span class="br0">&#40;</span><span class="st0">&#8216;ok&#8217;</span><span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">&#8217;success&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&lt;/script&gt;</div>
</li>
</ol>
</div>
<p>ส่วนนี้เป็นการเรียกใช้งาน plugin ครับ โดยที่ผมให้ validation เงื่อนไข<br />
field:name, gender จำเป็นต้องต้องกรอก</p>
<p>ส่วนตรง errorPlacemanet นั้น ผมบังครับให้ข้อความ Error ต้องแสดงนะจุดไหน (จริงๆ ถ้าไม่ serious ก็ไม่ต้องก็ได้ มันจะไปแสดงหลัง input)</p>
<p>ตรง success นั้นผม ก็บอกว่า ถ้าผ่านจะให้ มันทำอะไรกับช่วง message error แทน ที่ผมทำคือ แสดง message &#8220;ok&#8221; แล้วก็เปลี่ยน class สีมันซะหน่อย </p>
<p>นอกจากนี้มันยัง config ได้อีกเยอะเลย เช่น </p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">rules: <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; username: <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; required: <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; minlength: <span class="nu0">5</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; remote: check.<span class="me1">php</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; email: <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; required: <span class="kw2">true</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; email: <span class="kw2">true</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; emailconfirm: <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; equalTo: <span class="st0">&#8216;#email&#8217;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span>,</div>
</li>
<li class="li2">
<div class="de2">messages: <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; username: <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; required: <span class="st0">&#8216;กรอกด้วยๆ&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; remote: <span class="st0">&#8216;user นี้มีคนใช้อยู่&#8217;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>แบบนี้จะเป็นการ ระบุ validate แบบเต็มๆ รวมทั้งแก้ default message บางตัวด้วย ยังไง ตรงนี้ผมขอฝากให้อ่าน <a href="http://docs.jquery.com/Plugins/Validation">manual</a> เอาเองละกัน มันค่อนข้างจะเยอะ จริงๆ </p>
<p><strong>HTML:</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;form method=&quot;post&quot; name=&quot;demo&quot; id=&quot;demo&quot; action=&quot;#&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;fieldset&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;legend&gt;jQueryTips Demo&lt;/legend&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;table&gt;
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Name&lt;/th&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;cname&quot; value=&quot;&quot; class=&quot;txt&quot; /&gt;&lt;/td&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td class=&quot;form-message&quot;&gt;&lt;/td&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;th&gt;Gender&lt;/th&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label&gt;&lt;input type=&quot;radio&quot; name=&quot;gender&quot; value=&quot;1&quot; /&gt; Male&lt;/label&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;label&gt;&lt;input type=&quot;radio&quot; name=&quot;gender&quot; value=&quot;2&quot; /&gt; Female&lt;/label&gt;
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td class=&quot;form-message&quot;&gt;&lt;/td&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;tr&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;&lt;/td&gt;
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;td colspan=&quot;2&quot;&gt;&lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;&lt;/td&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/tr&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/table&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;/fieldset&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;/form&gt;</div>
</li>
</ol>
</div>
<p>ส่วนนี่เป็นตัว อย่าง HTML ครับ </p>
<p>และเพื่อไม่ให้เสียเวลา และสร้างความเข้าใจมากขึ้น ผมได้เขียนตัวอย่างขึ้นมาไฟล์นึง พร้อมทั้งให้ Download ไปลองแกะกันดู ที่นี่ครับ</p>
<p><a href="http://www.jquerytips.com/example/validation/">Sample</a></p>
<p>คิดว่าหลังจากได้ดูตัวอย่างและลอง view source ก็น่าจะเข้าใจได้ไม่ยากครับ แต่ว่าลูกเล่น ของ plugin ตัวนี้ นี่มีอีกเพียบเลย ครับ ยังไง ลอง ดูที่ <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">Official Site</a> เอาเลย</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2009/04/30/jquery-validation-plugin/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>เปลี่ยน Font เน่าๆ ให้ดูสวยงามด้วย jQuery + sIFR</title>
		<link>http://www.jquerytips.com/2009/04/22/jquery-sifr/</link>
		<comments>http://www.jquerytips.com/2009/04/22/jquery-sifr/#comments</comments>
		<pubDate>Wed, 22 Apr 2009 16:00:51 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[sIFR]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=398</guid>
		<description><![CDATA[บทความนี้มันมีที่มาครับ เนื่องจาก วันก่อน เห็น K.Non และ K.Golf คุยกันใน Twitter ว่า &#8220;เว็บไซด์ thairath ใช้ sIFR ด้วย&#8221; ก็เลยทำให้เกิดความสงสัยครับ ว่า ไอ้ sIFR เนี่ย มันคืออะไรหว่า? 
และก็ไม่รอช้า ถามพี่ Google ในทันที และก็ไม่ผิดหวัง สุดท้ายก็ได้คำตอบมาว่า
ไอ้ sIFR เนี่มันคือโปรเจคของ พี่ Mike Davidson ซึ่งมีหน้าที่คือ นำ Flash มาแทนที่ตัวอักษรภายใน Element ที่ระบุ โดยที่เราสามารถ ใช้ Font จากที่ไหนก็ได้ 
แล้วก็ลองทำดูได้หน้าตาออกมาแบบนี้ Online Demo (ลอง view Source ดูประกอบ)
หลักการของมันมีอยู่นิดเดียวเองครับ
1. ใช้ js ในการส่งค่า ระบุ พารามิเตอร์ให้กับ Flash [...]]]></description>
			<content:encoded><![CDATA[<p>บทความนี้มันมีที่มาครับ เนื่องจาก วันก่อน เห็น <a href="http://twitter.com/mp3wizard">K.Non</a> และ <a href="http://twitter.com/igolf">K.Golf</a> คุยกันใน Twitter ว่า &#8220;เว็บไซด์ thairath ใช้ sIFR ด้วย&#8221; ก็เลยทำให้เกิดความสงสัยครับ ว่า ไอ้ <a href="http://en.wikipedia.org/wiki/Scalable_Inman_Flash_Replacement">sIFR</a> เนี่ย มันคืออะไรหว่า? </p>
<p>และก็ไม่รอช้า ถามพี่ <a href="http://www.google.co.th/">Google</a> ในทันที และก็ไม่ผิดหวัง สุดท้ายก็ได้คำตอบมาว่า</p>
<p>ไอ้ sIFR เนี่มันคือโปรเจคของ พี่ <a href="http://www.mikeindustries.com/blog/sifr/">Mike Davidson</a> ซึ่งมีหน้าที่คือ นำ Flash มาแทนที่ตัวอักษรภายใน Element ที่ระบุ โดยที่เราสามารถ ใช้ Font จากที่ไหนก็ได้ </p>
<p>แล้วก็ลองทำดูได้หน้าตาออกมาแบบนี้ <a href="http://jquerytips.com/example/sifr/demo.html">Online Demo</a> (ลอง view Source ดูประกอบ)</p>
<p>หลักการของมันมีอยู่นิดเดียวเองครับ<span id="more-398"></span><br />
1. ใช้ js ในการส่งค่า ระบุ พารามิเตอร์ให้กับ Flash รวมไปถึงการดึง text ภายใน element ที่ระบุ ส่งค่าให้กับ flash<br />
2. Flash (swf) ทำการ Render กลับมา</p>
<p>แค่นี้เองครับ แต่ว่านอกจากนี้มันยังสามารถระบุ parameters ได้อีกจำนวนนึง เช่น สี font, สี link, ขนาด, padding, etc.</p>
<p>และที่สำคัญมัน support SEO เต็มตรีนเลย เพราะมันไม่ได้ embed มาทันที แต่อาศัยความสามารถของ js ในการ create object on the fly มา ฉะนั้น ก็ให้ Bot อ่าน Source Code เดิมๆ กันต่อไป</p>
<p>จากนั้นผมก็ลองเอามาเล่นพักนึง เห็นการเรียก element แบบนี้แล้วมันทำให้นึกถึง jQuery แฮะ เลยเดาเอาว่า ต้องมี เทพๆ เขียน plugin ให้กรู ใช้เป็นแน่แท้ และก็&#8230;..</p>
<p>มีจริงๆ ครับ <a href="http://www.eona.com/sifr/">jQuery sIFR Plugin</a></p>
<p>พอได้แบบนี้แล้วทำให้วิธีการใช้งานสะดวกมากขึ้นเลย ทีนี้เรามาเริ่มต้นใช้งานมันดูกัน</p>
<p>ก่อนอื่นก็ไปโหลด plugin ซึ่งจะประกอบไปด้วย 3 ไฟล์ ดังนี้<br />
1. <a href="http://www.eona.com/sifr/javascript/jquery.sifr.min.js">jQuery Sifr Plugin v1.5</a><br />
<em>มีหน้าที่ในการเขียน syntax js เอาไปติดต่อกับ flash ซึ่งถือเป็นหัวใจเลยครับ </em></p>
<p>2. <a href="http://www.eona.com/sifr/javascript/jquery.min.js">jQuery </a><br />
<em>อันนี้ก็รู้ๆ กันอยู่ jQuery Core นั่นเอง</em></p>
<p>3. <a href="http://www.eona.com/sifr/javascript/jquery.flash.min.js">jQuery Flash Plugin v1.0.1</a><br />
อันนี้จะถูกเรียกใช้ใน plugin อีกทีเพื่อทำการ embed flash โดยที่เราไม่ต้องมากังวลว่า มันจะต้องใช้ embed หรือ object ในการใช้งาน flash และความสามารถอื่นๆ</p>
<p>4. <a href="http://jquerytips.com/example/sifr/resources.zip">Fonts</a><br />
<em>อันนี้ผมเอาบางส่วนของชาวบ้านมาให้ใช้ทดสอบ</em><br />
*** ขอขอบคุณ Font ภาษาไทย จาก <a href="http://www.f0nt.com">f0nt.com</a> ***</p>
<p>เริ่มต้นการใช้งานก็เรียกไฟล์ js แบบนี้ครับ</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;script src=<span class="st0">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;script src=<span class="st0">&quot;jquery.flash.min.js&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;</div>
</li>
<li class="li1">
<div class="de1">&lt;script src=<span class="st0">&quot;jquery.sifr.min.js&quot;</span> type=<span class="st0">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;</div>
</li>
</ol>
</div>
<p>ต่อจากนั้นเรียกใช้งาน plugin และทำการ define ของ element ที่จะถูกเปลี่ยนแปลงค่า </p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span>document<span class="br0">&#41;</span>.<span class="me1">ready</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span class="me1">sifr</span><span class="br0">&#40;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; path: <span class="st0">&#8216;resources/&#8217;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fontSize: <span class="nu0">30</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; color: <span class="st0">&#8216;#FF3300&#8242;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; save: <span class="kw2">true</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&#8216;h1&#8242;</span><span class="br0">&#41;</span>.<span class="me1">sifr</span><span class="br0">&#40;</span><span class="br0">&#123;</span> font: <span class="st0">&#8216;iannnnnvcdlight&#8217;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&#8216;h2&#8242;</span><span class="br0">&#41;</span>.<span class="me1">sifr</span><span class="br0">&#40;</span><span class="br0">&#123;</span> font: <span class="st0">&#8216;AvantGarde Md BT&#8217;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&#8216;h3&#8242;</span><span class="br0">&#41;</span>.<span class="me1">sifr</span><span class="br0">&#40;</span><span class="br0">&#123;</span> font: <span class="st0">&#8216;Medici Text&#8217;</span> <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&lt;/script&gt;</div>
</li>
</ol>
</div>
<p>ในที่นี้จุดที่สำคัญๆ ก็คือ </p>
<p><strong>path: &#8216;resources/&#8217;</strong> เป็นการระบุไปยังตำแหน่งจัดเก็บ fonts ของเรา </p>
<p><strong>$(&#8216;h1&#8242;).sifr({ font: &#8216;iannnnnvcdlight&#8217; });</strong> เป็นการเลือก font จาก folder path และระบุให้ element h1 ทั้งหมด ถูกเปลี่ยนค่า</p>
<p>สำหรับ parameters อื่นๆ ดูได้ <a href="http://www.eona.com/sifr/#description">ที่นี่</a> ครับ</p>
<p><strong>HTML Code</strong></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;h1&gt;Test ทดสอบระบบ สวัสดีครับ&lt;/h1&gt;</div>
</li>
</ol>
</div>
<p>text ทั้งหมดใน element h1 จะถูก แทนที่ด้วย flash พร้อมกับ font ที่เราระบุไป ลองดูตัวอย่างที่นี่ครับ<br />
<a href="http://jquerytips.com/example/sifr/demo.html">Online Demo</a></p>
<p><a href="http://jquerytips.com/example/sifr/sifr.zip">All source code and example available to download here</a></p>
<p>โอ้ว พระเจ้า มันยอดมากจริงๆ เลยใช่มั้ยล่ะครับ!!!</p>
<p>เพิ่มเติมอีกนิดครับ สำหรับวิธีการทำ Font ใช้งานเอง ผมไปเห็นบทความ ภาษาไทยของท่านนึง เขียนได้ดีแล้ว เลยขอนำมาอ้างอิง โดยไม่เขียนใหม่ ลองดูกันได้ที่ link ทางด้านล่างครับ<br />
<a href="http://itshee.exteen.com/20090219/jquery-sifr">http://itshee.exteen.com/20090219/jquery-sifr</a></p>
<p>ไม่ก็ใช้วิธี Convert online เอา สำหรับคนที่ไม่มี โปรแกรม Flash<br />
<a href="http://www.sifrgenerator.com/wizard.html">http://www.sifrgenerator.com/wizard.html</a><br />
<a href="http://www.ianpurton.com/sifr/">http://www.ianpurton.com/sifr/</a></p>
<p><strong>ปัญหาที่พบ</strong><br />
1. ไม่สามารถตัดคำในภาษาไทยได้ ต้องอาศัยการเคาะวรรคเอง<br />
2. วรรณยุกต์ลอย</p>
<p>Ps. ตอนนี้เค้าแก้ วรรณยุกต์ลอยกันได้แล้วนะเออ ลองไปหาคำตอบ <a href="http://www.f0nt.com/forum/index.php/topic,15892.0.html">ที่นี่</a> ครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2009/04/22/jquery-sifr/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>mcDropDown ปลั๊กอินที่หน้าตาคล้ายๆ ปุ่ม Start ของ Windows</title>
		<link>http://www.jquerytips.com/2009/03/21/mcdropdown-jquery/</link>
		<comments>http://www.jquerytips.com/2009/03/21/mcdropdown-jquery/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 18:22:32 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=276</guid>
		<description><![CDATA[ลองสังเกตุ กันบ้างมั้ยครับ เว็บสมัยนี้ พยายามกันอย่างหนักที่จะ ทำยังไงก็ได้ ให้มีเนื้อหาที่ครบถ้วนสมบูรณ์ โดยที่ไม่ทำให้ layout เสีย และ ใช้พื้นที่น้อยที่สุด โดยการทำดังนี้ ผมก็เห็นมาค่อนข้างจะหลายเทคนิควิธี อาทิ เช่น
Tabs &#8211; การแสดงผล โดยแบ่งออกเป็น tab ด้านบน แล้วค่อยๆคลิกเปลี่ยนไป
Fade &#8211; การแสดงผล โดยการค่อยๆ Fade Content เข้ามา โดยอาจจะมีปุ่ม Next/Back ให้ด้วย
Slide, Toggle &#8211; การแสดงผลโดย ซ่อน Content เอาไว้ก่อนจนกว่า user จะคลิกแสดงมันออกมา
แล้วก็ยังอื่นๆ อีกมากที่นิยมกัน&#8230;
เอาล่ะเข้าเรื่องๆ วันนี้ผมเองก็เห็น plugin ตัวนึงซึ่งช่วยในการทำงานแบบนี้ได้ดี โดยเป็น plugin ที่ทำงานกับ Input:text
ลองไปดูรูปหน้าตามันกัน

ครับ มันเป็น plugin ที่ช่วยในเรื่องของการ Select Data แบบเป็นลำดับชั้นนั่นเอง โดยจะอาศัยการทำงาน ด้วย Tag  [...]]]></description>
			<content:encoded><![CDATA[<p>ลองสังเกตุ กันบ้างมั้ยครับ เว็บสมัยนี้ พยายามกันอย่างหนักที่จะ ทำยังไงก็ได้ ให้มีเนื้อหาที่ครบถ้วนสมบูรณ์ โดยที่ไม่ทำให้ layout เสีย และ ใช้พื้นที่น้อยที่สุด โดยการทำดังนี้ ผมก็เห็นมาค่อนข้างจะหลายเทคนิควิธี อาทิ เช่น</p>
<p>Tabs &#8211; การแสดงผล โดยแบ่งออกเป็น tab ด้านบน แล้วค่อยๆคลิกเปลี่ยนไป</p>
<p>Fade &#8211; การแสดงผล โดยการค่อยๆ Fade Content เข้ามา โดยอาจจะมีปุ่ม Next/Back ให้ด้วย<span id="more-276"></span></p>
<p>Slide, Toggle &#8211; การแสดงผลโดย ซ่อน Content เอาไว้ก่อนจนกว่า user จะคลิกแสดงมันออกมา</p>
<p>แล้วก็ยังอื่นๆ อีกมากที่นิยมกัน&#8230;</p>
<p>เอาล่ะเข้าเรื่องๆ วันนี้ผมเองก็เห็น plugin ตัวนึงซึ่งช่วยในการทำงานแบบนี้ได้ดี โดยเป็น plugin ที่ทำงานกับ Input:text</p>
<p><span style="color: #ff6600;"><strong>ลองไปดูรูปหน้าตามันกัน</strong></span></p>
<p><a href="http://www.jquerytips.com/wp-content/uploads/2009/03/mcdropdown_preview.png"><img class="alignnone size-medium wp-image-277" title="mcdropdown_preview" src="http://www.jquerytips.com/wp-content/uploads/2009/03/mcdropdown_preview-297x300.png" alt="mcdropdown_preview" width="297" height="300" /></a></p>
<p>ครับ มันเป็น plugin ที่ช่วยในเรื่องของการ Select Data แบบเป็นลำดับชั้นนั่นเอง โดยจะอาศัยการทำงาน ด้วย Tag  Ul, Li เป็นลำดับชั้น</p>
<p>plugin ตัวนี้ชื่อว่า <strong><a href="http://www.givainc.com/labs/mcdropdown_jquery_plugin.htm" target="_blank">mcDropDown</a></strong> ซึ่งติดอยู่ในส่วน Popular plugins ในเวบ<a href="http://jquery.com" target="_blank"> jQuery</a> เองด้วย</p>
<p>ซึ่งวิธีใช้งานผมไม่ขออธิบายซ้ำนะครับ เพราะว่า เว็บไซด์ของทางผู้พัฒนา เขียนไว้ค่อนข้างละเอียด และผมลองดูก็ยังไม่เจอปัญหาอะไร ใช้งานค่อนข้างง่ายเลยทีเดียว</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2009/03/21/mcdropdown-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>มา Translate กันเถอะ พี่ GG เค้าจัดมาแล้ว</title>
		<link>http://www.jquerytips.com/2009/03/06/jquery-with-gogole-translate/</link>
		<comments>http://www.jquerytips.com/2009/03/06/jquery-with-gogole-translate/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 16:36:05 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Others]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Gogole]]></category>
		<category><![CDATA[Jsonp]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=261</guid>
		<description><![CDATA[Google Translate
ว้าว ขณะที่ Post ข้อความอยู่นี้ เชื่อมั้ยครับว่าผมเขียนบทความ ลงใน jQueryTips นี้ทั้งหมดกี่บทความแล้ว 80 !!!!! ใช่แล้วตั้ง 80 แน่ะ รวมบทความนี้ก็จะเป็นบทความที่ 81 ไม่น่าเชื่อเลย ว่าตัวเองจะเขียนได้มาไกลถึงขนาดนี้ 555++ 
ตอนแรกก็กะเขียนเล่นๆ คิดว่า วัน สองวันตัวเอง คงเบื่อ ไปๆมาๆ นี่เขียนกันเป็นปีเลย อืมม์ คิดๆแล้วก็ ภูมิใจแฮะ วันนี้เดี๋ยว export มา backup ซะหน่อยดีกว่า ^^
เอาล่ะๆ มาเข้าเรื่องที่จะเขียนวันนี้กันเลยดีกว่า &#8220;ภาษาอังกฤษ&#8221; -*- เชื่อแน่ๆ เลยครับว่าปัญหาเรื่อง ภาษา ไม่แข็งแรงนั้น สั่งสมอยู่กับคนไทย มานานแสนนาน ทำให้เราขาดโอกาส และการเรียนรู้ที่ดีๆ จาก international website, e-book หรือสื่อ ภาษาต่างประเทศ อะไรต่อมิอะไรไปไม่ใช่น้อย
แต่ผมคิดว่า ต่อไปนี้ปัญหาอาจจะเบาบางลง ด้วยท่านเทพแห่งโลกไซเบอร์อย่างพี่ [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.jQueryTips.com/example/GTranslate/" target="_blank">Google Translate</a></p>
<p>ว้าว ขณะที่ Post ข้อความอยู่นี้ เชื่อมั้ยครับว่าผมเขียนบทความ ลงใน jQueryTips นี้ทั้งหมดกี่บทความแล้ว 80 !!!!! ใช่แล้วตั้ง 80 แน่ะ รวมบทความนี้ก็จะเป็นบทความที่ 81 ไม่น่าเชื่อเลย ว่าตัวเองจะเขียนได้มาไกลถึงขนาดนี้ 555++ </p>
<p>ตอนแรกก็กะเขียนเล่นๆ คิดว่า วัน สองวันตัวเอง คงเบื่อ ไปๆมาๆ นี่เขียนกันเป็นปีเลย อืมม์ คิดๆแล้วก็ ภูมิใจแฮะ วันนี้เดี๋ยว export มา backup ซะหน่อยดีกว่า ^^</p>
<p>เอาล่ะๆ มาเข้าเรื่องที่จะเขียนวันนี้กันเลยดีกว่า &#8220;ภาษาอังกฤษ&#8221; -*- เชื่อแน่ๆ เลยครับว่าปัญหาเรื่อง ภาษา ไม่แข็งแรงนั้น สั่งสมอยู่กับคนไทย มานานแสนนาน ทำให้เราขาดโอกาส และการเรียนรู้ที่ดีๆ จาก international website, e-book หรือสื่อ ภาษาต่างประเทศ อะไรต่อมิอะไรไปไม่ใช่น้อย</p>
<p>แต่ผมคิดว่า ต่อไปนี้ปัญหาอาจจะเบาบางลง ด้วยท่านเทพแห่งโลกไซเบอร์อย่างพี่ <a href="http://www.google.com">Big Google</a> เพราะตอนนี้ ท่านได้ออก Language Service ชุดของการ Translate ใน version th -> en, en -> th หรือ ภาษาอื่นๆ อีกเยอะแยะมาแล้ว<span id="more-261"></span></p>
<p>จะแปลทั้งเวบ หรือจะแปลเป็นประโยค ก็สะดวกสบาย รวดเร็ว ไปลองกันดูได้ ที่นี่ <a href="http://translate.google.co.th/">Google Translate</a></p>
<p>เห็นมั้ย เจ๋งโครต แต่ถ้าคิดว่าวันนี้ ผมจะมาแนะนำ Service แค่นี้ล่ะก็ ผิดถนัดครับ ผมมีอะไรๆ ทีเด็ดกว่านี้เยอะรอให้ไปอ่านกันอยู่แล้ว&#8230;&#8230;</p>
<p>รู้มั้ยครับว่า <a href="http://code.google.com/apis/ajaxlanguage/documentation/">Google AJAX Language</a> ก็มี <a href="http://code.google.com/apis/ajaxlanguage/documentation/">API</a> ด้วย ซึ่งการใช้งานก็โครตจะง่าย เพราะมันถูก plug เข้ามาอยู่ในชุดของ Google JS API แล้ว ทำให้เราเรียกโหลดมาจาก Google ได้เลย โดยไม่จำเป็นต้องมา include อะไรวุ่นวาย </p>
<p>ไม่เชื่อเอาโคดชุดนี้ไปรันดู</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;html&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &lt;head&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &lt;script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi&quot;&gt;&lt;/script&gt;
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &lt;script type=&quot;text/javascript&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; google.load(&quot;language&quot;, &quot;1&quot;);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; function translate() {
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; var text = document.getElementById(&quot;text&quot;).innerHTML;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; google.language.detect(text, function(result) {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; if (!result.error &amp;&amp; result.language) {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; google.language.translate(text, result.language, &quot;en&quot;,
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function(result) {
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var translated = document.getElementById(&quot;translation&quot;);
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (result.translation) {
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; translated.innerHTML = result.translation;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; });
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; }
</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &lt;/script&gt;
</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &lt;/head&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &lt;body&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &lt;div&gt;&lt;span id=&quot;text&quot;&gt;สวัสดี ชาวโลก&lt;/span&gt;&lt;input type=&quot;button&quot; value=&quot;translate&quot; onclick=&quot;translate()&quot; /&gt;&lt;/div&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &lt;div id=&quot;translation&quot;&gt;&lt;/div&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &lt;/body&gt;
</div>
</li>
<li class="li2">
<div class="de2">&lt;/html&gt;</div>
</li>
</ol>
</div>
<p>ซึ่งใน API ชุดนี้ของ GG จะประกอบไปด้วย สองส่วนหลักๆก็คือ<br />
1. Detect language<br />
ตัวนี้เป็นตัวตรวจสอบภาษาที่จะแปลครับ ว่าเป็นภาษาอะไร โดยเราไม่จำเป็นต้องบอก GG ว่าเรากำลังจะแปลจาก ภาษาอะไรเป็นภาษาอะไร โดยแค่เราส่ง กลุ่มที่จะแปลเข้าไป GG จะบอกมาเองว่าเรากำลังทำงานกับภาษาอะไร จะคืนค่าเป็น th, en, jp หรือ ภาษาอื่นๆ</p>
<p>2. Translate<br />
แน่นอนอีกตัวคือหัวใจครับ ตัวแปลนั่นเอง โดยตัวแปลนี้เราสามารถส่ง text เข้าไปแปล โดยต้องระบุ </p>
<p>text = ประโยคที่จะทำการแปล<br />
source = แปลจากภาษาอะไร เช่น en (ตรงนี้เราจะสามารถใช้ api ชุด detect lang ทำงานแทนได้)<br />
destination = แปลมาเป็นภาษาอะไร เช่น th</p>
<p>ซึ่งจากที่ผมเอา Firebug จับมา การทำงานของ API Google ชุดนี้ก็คือ JSONP นั่นเอง</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">http://www.google.com/uds/Gtranslate?callback=google.language.callbacks.id101&amp;context=22&amp;q=สวัสดีชาวโลก&amp;langpair=th|en&amp;key=notsupplied&amp;v=1.0</div>
</li>
</ol>
</div>
<p>เอาล่ะๆ ไอ้ที่บอกมาทั้งหมด มันแค่เกริ่นเท่านั้นเองอ่ะ ที่เป็นบทความวันนี้จริงๆ มันต้องเป็น jQuery แน่นอนอยู่แล้ว นี่ครับ</p>
<p><a href="http://sundaymorning.jaysalvat.com/">Sunday Morning jQuery Google Translate API</a></p>
<p>ซึ่งหน้าตาโดยรวมแล้ว ให้ 9/10 ครับ สวยงามน่าใช้ แถมใช้งานง่ายด้วย สามารถแปลแบบ กลุ่มคำ หรือแบบ คำเดี่ยวก็ได้ ใช้เป็น Dict ภายในเวบเลยก็ยังได้</p>
<p>ยังไงก็ลองไปเล่นกันดูนะครับ ผมคงไม่เขียนอธิบายวิธีใช้ เพราะเค้าเขียนไว้หมดแล้ว ไม่เข้าใจยังไง view source ดูกันเอาก็น่าจะพอเข้าใจอยู่ ตัวนี้ส่วนตัวผมถือว่าเป็น <strong>Plugin น้ำดี</strong> ตัวนึงเลยทีเดียว </p>
<p>อันนี้เป็นตัวอย่างที่ผมลองเอามาเขียนเล่นๆครับ</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">http://www.jQueryTips.com/example/GTranslate/</div>
</li>
</ol>
</div>
<p>เอ แต่ถ้าอ่าน เว็บเค้าแล้วไม่เข้าใจ ก็ลองอย่าลืมใช้ Google Translate มาเป็นภาษาแม่ เราดูนะครับ 555++ </p>
<p>วันนี้ลาไปก่อนแค่นี้ล่ะ จะไปแรดข้างนอกละ ^^</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2009/03/06/jquery-with-gogole-translate/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>jWYSIWYG เปลี่ยน Textarea เชยๆ ให้ดูหรูหรามีระดับ</title>
		<link>http://www.jquerytips.com/2009/03/04/jwysiwyg/</link>
		<comments>http://www.jquerytips.com/2009/03/04/jwysiwyg/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 13:32:20 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[WYSIWYG]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=259</guid>
		<description><![CDATA[หวัดดีครับ สาวก jQuery ทั้งหลาย ^^
วันนี้ผมมี Plug in น่ารักๆ อีกตัวมาแนะนำกันอีกแล้ว จำได้มั้ยครับ เมื่อนานมาแล้วผมเคยเอา MarkItUp ซึ่งเป็น jQuery Editor Plugin มาแนะนำกันไป
มาวันนี้ผมก็มีของคล้ายๆกันมาให้ชมกันอีกแล้ว จะต่างกันก็เพียงตัวที่ผมจะแนะนำในวันนี้มันเป็นการ แสดงผลแบบ WYSIWYG (What You See It What You Get) เท่านั้น 
ลองไปดู Demo ที่ เวบไซด์ผู้พัฒนากันเอาเองเลยดีกว่า 
Plugin ตัวนี้มีชื่อว่า jWYSIWYG ครับ ความสามารถโดยสรุปก็คือ เปลี่ยนช่อง Textarea ที่จืดชืด ให้มีสีสัน และ Tools เล็กๆ น้อยๆ มาให้พอหอมปากหอมคอกัน 
แต่ว่ามันก็ยังมีลูกเล่นเพิ่มเติมคือเราสามารถเขียน Exec Function เข้าไปได้เองอีกด้วย ใน Demo จะเรียกว่า Add custom [...]]]></description>
			<content:encoded><![CDATA[<p>หวัดดีครับ สาวก jQuery ทั้งหลาย ^^</p>
<p>วันนี้ผมมี Plug in น่ารักๆ อีกตัวมาแนะนำกันอีกแล้ว จำได้มั้ยครับ เมื่อนานมาแล้วผมเคยเอา <a href="http://www.jquerytips.com/2008/06/22/markitup-jquery-plugin/">MarkItUp</a> ซึ่งเป็น jQuery Editor Plugin มาแนะนำกันไป</p>
<p>มาวันนี้ผมก็มีของคล้ายๆกันมาให้ชมกันอีกแล้ว จะต่างกันก็เพียงตัวที่ผมจะแนะนำในวันนี้มันเป็นการ แสดงผลแบบ WYSIWYG (What You See It What You Get) เท่านั้น <span id="more-259"></span></p>
<p>ลองไปดู <a href="http://projects.bundleweb.com.ar/jWYSIWYG/">Demo</a> ที่ เวบไซด์ผู้พัฒนากันเอาเองเลยดีกว่า </p>
<p>Plugin ตัวนี้มีชื่อว่า <a href="http://projects.bundleweb.com.ar/jWYSIWYG/">jWYSIWYG</a> ครับ ความสามารถโดยสรุปก็คือ เปลี่ยนช่อง Textarea ที่จืดชืด ให้มีสีสัน และ Tools เล็กๆ น้อยๆ มาให้พอหอมปากหอมคอกัน </p>
<p>แต่ว่ามันก็ยังมีลูกเล่นเพิ่มเติมคือเราสามารถเขียน Exec Function เข้าไปได้เองอีกด้วย ใน Demo จะเรียกว่า Add custom controls ครับ</p>
<p>สรุปแล้ว ผมว่า plugin ตัวนี้เป็นของเล่นเล็กๆ ที่ดูน่าสนุกดีทีเดียวครับ ลองไปเล่นดูกัน</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2009/03/04/jwysiwyg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox&#8217;s Plugins ที่ผมเลือกใช้</title>
		<link>http://www.jquerytips.com/2009/02/04/firefox-plugins-for-developer/</link>
		<comments>http://www.jquerytips.com/2009/02/04/firefox-plugins-for-developer/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 04:52:36 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Others]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=244</guid>
		<description><![CDATA[วันนี้ไม่ได้มีบทความอะไรมาแนะนำ ไม่ได้หมดมุขนะครับ แต่พอดีอยากจะเขียนบทความนี้ก่อน นั่นก็คือเรื่องของ plugin ใน Firefox ในมุมมองของ Developer ที่ ตัวผมเองคิดว่า มันมีประโยชน์เอามากๆ เลยทีเดียว พวกนี้เป็น plugin ที่ผมจะต้องลงก่อนเสมอ หลังจาก Format เครื่อง ลองมาดูกันครับ ว่าผมใช้อะไรบ้าง
ColorZilla
ตัวนี้ผมเอาไว้จับสีในเวบของชาวบ้าน โดยเฉพาะ มันมี Eyedropper เหมือนพวกโปรแกรมแต่งภาพนั่นแหละ
Dafizilla ViewSourceWith
ตัวนี้เอาไว้ View Source Code กับ Editor ที่เราเลือกไว้ โดยส่วนตัวผมเอามา View ใน Editplus 
Delicious Bookmarks
ตัวนี้เป็น plugin เสริมของ online bookmark ชื่อดังที่มี Yahoo Inc. เป็นเจ้าของ มีหน้าที่เอาไว้ Bookmark เวบที่ผมชอบ
Firebug
ตัวนี้คงไม่ต้องบรรยายอะไร plugin เทพๆ แบบนี้ เอาไว้ทำงานทุกอย่าง ทั้งจับ Request, [...]]]></description>
			<content:encoded><![CDATA[<p>วันนี้ไม่ได้มีบทความอะไรมาแนะนำ ไม่ได้หมดมุขนะครับ แต่พอดีอยากจะเขียนบทความนี้ก่อน นั่นก็คือเรื่องของ plugin ใน Firefox ในมุมมองของ Developer ที่ ตัวผมเองคิดว่า มันมีประโยชน์เอามากๆ เลยทีเดียว พวกนี้เป็น plugin ที่ผมจะต้องลงก่อนเสมอ หลังจาก Format เครื่อง ลองมาดูกันครับ ว่าผมใช้อะไรบ้าง</p>
<p><strong>ColorZilla</strong><br />
ตัวนี้ผมเอาไว้จับสีในเวบของชาวบ้าน โดยเฉพาะ มันมี Eyedropper เหมือนพวกโปรแกรมแต่งภาพนั่นแหละ</p>
<p><strong>Dafizilla ViewSourceWith</strong><br />
ตัวนี้เอาไว้ View Source Code กับ Editor ที่เราเลือกไว้ โดยส่วนตัวผมเอามา View ใน Editplus <span id="more-244"></span></p>
<p><strong>Delicious Bookmarks</strong><br />
ตัวนี้เป็น plugin เสริมของ online bookmark ชื่อดังที่มี Yahoo Inc. เป็นเจ้าของ มีหน้าที่เอาไว้ Bookmark เวบที่ผมชอบ</p>
<p><strong>Firebug</strong><br />
ตัวนี้คงไม่ต้องบรรยายอะไร plugin เทพๆ แบบนี้ เอาไว้ทำงานทุกอย่าง ทั้งจับ Request, Inspect DOM, Edit Css, etc ตัวนี้เทพมาก ทำได้ทุกอย่างที่ผมต้องการเลย</p>
<p><strong>Greasemonkey</strong><br />
ไอ้นี่ก็สุดยอดครับ เอาไว้เขียน JS ทดสอบในเวบเราเอง หรือเวบชาวบ้านก็ได้ ที่สำคัญ Ajax ของ Plugin ตัวนี้ Cross Domain ได้ด้วย</p>
<p><strong>Html Validator</strong><br />
อันนี้เอาไว้ Validate HTML แบบ Realtime</p>
<p><strong>IE Netrender</strong><br />
ตัวนี้เอาไว้ Render หน้าเวบใน Engine Version ต่างๆ ของ Browser เจ้าปัญหา IE นั่นเอง โดยมันมีตั้งแต่ IE5.5 &#8211; IE8 Beta แต่ขอบอก มันไม่ Work อย่างที่คิด มีติดๆ ไว้งั้นแหละ</p>
<p><strong>IE Tab</strong><br />
ตัวนี้เอาไว้ Switch ใช้ Engine ของ IE ในหน้าของ Firefox สะดวกดีนะ</p>
<p><strong>Library Detector</strong><br />
อันนี้เอาไว้ Detect เวบชาวบ้าน ว่าใช้ JS Framework อะไร ถึงออกมาหะรูหะรา แบบนั้น</p>
<p><strong>MeasureIT</strong><br />
ตัวนี้เอาไว้ วัด Size ในหน้าเวบเพจ</p>
<p><strong>SearchStatus</strong><br />
เอาไว้เช็คเรื่อง SEO พวก PR, Index, Alexa</p>
<p><strong>TinyUrl Creator</strong><br />
สร้าง URL แบบสั้นๆ ผ่าน Service ของ TinyUrl</p>
<p><strong>Web Developer</strong><br />
ตัวนี้ก็ของเทพ ชัดๆ การทำงานบางตัวก็ ซ้ำกับ Firebug ส่วนมากผมจะเอาไว้ ดู Element ต่างๆ รวมไปถึง header, cookie ที่สำคัญ ผมเอาไว้ Generate Source Code ที่ผ่าน JS Function มาแล้ว รวมไปถึงปิด คำสั่งบางตัว บางโอกาส เพื่อทำการ Test, Debug</p>
<p><strong>Yslow</strong><br />
เป็นตัวเสริมของ Firebug เอาไว้ Test Performace ของ เวบ</p>
<p>นี่ล่ะครับ Plugins ที่ผมเลือกใช้ เพื่อนๆล่ะ มีตัวไหนมาแนะนำผมกันบ้าง ^^</p>
<p>ไว้ครั้งหน้าจะมาจบเรื่อง CI แล้วก็จะกลับมาสู่ Version ปกติของ jQueryTips กันนะครับ รับรองไม่ผิดหวัง เพราะว่า ผมไปสะสม เทคนิคต่างๆ รวมไปถึง ผึกยุทธ์ เพิ่มขึ้น พอจะมีเรื่องมาเล่าแล้วล่ะ </p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2009/02/04/firefox-plugins-for-developer/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>มาดูวิธีการเขียน Select Boxes Multi Level แบบ Line:Line</title>
		<link>http://www.jquerytips.com/2008/12/01/plugin-select-boxes-multilevel/</link>
		<comments>http://www.jquerytips.com/2008/12/01/plugin-select-boxes-multilevel/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 05:37:05 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=183</guid>
		<description><![CDATA[วันนี้จะมาพูดถึงเรื่อง jQuery&#8217;s Plugin กันอีกแล้ว พักหลังๆ ถ้าสังเกตุกัน จะเห็นได้ว่า ผมมักจะเขียนแต่เรื่องนี้ เพราะว่ามันอัพเดทง่ายดี ไม่เปลืองสมอง ไม่เปลืองแรง 555++
แต่เอาล่ะ เดี๋ยวหลายๆ คนจะรู้สึกว่า เข้ามาอ่าน Blog นี้ไม่ได้อะไรกลับไปเลย วันนี้ก็เลยจะมาเปลี่ยนแนวซะหน่อย ก็คือ แนะนำ Plugin แต่จะเอา Code มาตีแผ่กัน เป็น บรรทัด ไป ดังนั้น เลยต้องเลือก plugin ที่มันสั้นๆ แต่มีประโยชน์กันหน่อย ก็คือตัวนี้ครับ
Select-Chain: Select boxes multilevel ประโยชน์ของมันก็คือการสร้าง input select แบบที่ Related กันหลายระดับ ถ้านึกไม่ออก ก็นึกภาพ
ประเทศ -> จังหวัด -> อำเถอ -> ตำบล
แต่ลักษณะการทำงานของ Plugin ตัวนี้ไม่ได้ทำการ จอง Array หรือ [...]]]></description>
			<content:encoded><![CDATA[<p>วันนี้จะมาพูดถึงเรื่อง jQuery&#8217;s Plugin กันอีกแล้ว พักหลังๆ ถ้าสังเกตุกัน จะเห็นได้ว่า ผมมักจะเขียนแต่เรื่องนี้ เพราะว่ามันอัพเดทง่ายดี ไม่เปลืองสมอง ไม่เปลืองแรง 555++</p>
<p>แต่เอาล่ะ เดี๋ยวหลายๆ คนจะรู้สึกว่า เข้ามาอ่าน Blog นี้ไม่ได้อะไรกลับไปเลย วันนี้ก็เลยจะมาเปลี่ยนแนวซะหน่อย ก็คือ แนะนำ Plugin แต่จะเอา Code มาตีแผ่กัน เป็น บรรทัด ไป ดังนั้น เลยต้องเลือก plugin ที่มันสั้นๆ แต่มีประโยชน์กันหน่อย ก็คือตัวนี้ครับ</p>
<p><a href="http://remysharp.com/2007/01/20/auto-populating-select-boxes-using-jquery-ajax/">Select-Chain</a>: Select boxes multilevel ประโยชน์ของมันก็คือการสร้าง input select แบบที่ Related กันหลายระดับ ถ้านึกไม่ออก ก็นึกภาพ<span id="more-183"></span></p>
<p><strong>ประเทศ -> จังหวัด -> อำเถอ -> ตำบล</strong></p>
<p>แต่ลักษณะการทำงานของ Plugin ตัวนี้ไม่ได้ทำการ จอง Array หรือ Object ไว้ก่อน แต่เป็นการ เรียกค่า JSON ผ่าน Ajax เป็นยังไง ลองไปดูกัน </p>
<p>และนี่คือ ไฟล์ Plugin เต็มๆ</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span>$<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; $.<span class="me1">fn</span>.<span class="me1">selectChain</span> = <span class="kw2">function</span> <span class="br0">&#40;</span>options<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> defaults = <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; key: <span class="st0">&quot;id&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value: <span class="st0">&quot;label&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> settings = $.<span class="me1">extend</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span class="br0">&#125;</span>, defaults, options<span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">return</span> <span class="kw1">this</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> $$ = $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $$.<span class="me1">change</span><span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> data = <span class="kw2">null</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">typeof</span> settings.<span class="me1">data</span> == <span class="st0">&#8217;string&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data = settings.<span class="me1">data</span> + <span class="st0">&#8216;&amp;&#8217;</span> + <span class="kw1">this</span>.<span class="kw3">name</span> + <span class="st0">&#8216;=&#8217;</span> + $$.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">typeof</span> settings.<span class="me1">data</span> == <span class="st0">&#8216;object&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data = settings.<span class="me1">data</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data<span class="br0">&#91;</span><span class="kw1">this</span>.<span class="kw3">name</span><span class="br0">&#93;</span> = $$.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; settings.<span class="me1">target</span>.<span class="me1">empty</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span class="me1">ajax</span><span class="br0">&#40;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url: settings.<span class="me1">url</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data: data,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: <span class="br0">&#40;</span>settings.<span class="me1">type</span> || <span class="st0">&#8216;get&#8217;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataType: <span class="st0">&#8216;json&#8217;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success: <span class="kw2">function</span> <span class="br0">&#40;</span>j<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> options = <span class="br0">&#91;</span><span class="br0">&#93;</span>, i = <span class="nu0">0</span>, o = <span class="kw2">null</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span>i = <span class="nu0">0</span>; i &lt; j.<span class="me1">length</span>; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; o = document.<span class="me1">createElement</span><span class="br0">&#40;</span><span class="st0">&quot;OPTION&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; o.<span class="me1">value</span> = <span class="kw1">typeof</span> j<span class="br0">&#91;</span>i<span class="br0">&#93;</span> == <span class="st0">&#8216;object&#8217;</span> ? j<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#91;</span>settings.<span class="me1">key</span><span class="br0">&#93;</span> : j<span class="br0">&#91;</span>i<span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; o.<span class="me1">text</span> = <span class="kw1">typeof</span> j<span class="br0">&#91;</span>i<span class="br0">&#93;</span> == <span class="st0">&#8216;object&#8217;</span> ? j<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#91;</span>settings.<span class="me1">value</span><span class="br0">&#93;</span> : j<span class="br0">&#91;</span>i<span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; settings.<span class="me1">target</span>.<span class="me1">get</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>.<span class="me1">options</span><span class="br0">&#91;</span>i<span class="br0">&#93;</span> = o;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setTimeout<span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; settings.<span class="me1">target</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">&#8216;option:first&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">&#8217;selected&#8217;</span>, <span class="st0">&#8217;selected&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span class="me1">parent</span><span class="br0">&#40;</span><span class="st0">&#8217;select&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span class="me1">trigger</span><span class="br0">&#40;</span><span class="st0">&#8216;change&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>, <span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error: <span class="kw2">function</span> <span class="br0">&#40;</span>xhr, desc, er<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">&quot;an error occurred&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span><span class="br0">&#40;</span>jQuery<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
</ol>
</div>
<p>ทีนี้เราลองมาแยกส่วนประกอบของ plugin ตัวนี้กัน ส่วนการส่งค่าจาก Server Side Script และวิธีใช้งาน ผมจะกล่าวถึงภายหลังนะครับ</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span>$<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">$.<span class="me1">fn</span>.<span class="me1">selectChain</span> = <span class="kw2">function</span> <span class="br0">&#40;</span>options<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw2">var</span> defaults = <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; key: <span class="st0">&quot;id&quot;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; value: <span class="st0">&quot;label&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; url: <span class="st0">&#8216;xxx.php&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; type: <span class="st0">&#8216;get&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; data: <span class="st0">&#8216;{ ajax: true, another: &#8216;</span>anotherValue<span class="st0">&#8216; }&#8217;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; <span class="kw2">var</span> settings = $.<span class="me1">extend</span><span class="br0">&#40;</span><span class="br0">&#123;</span><span class="br0">&#125;</span>, defaults, options<span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span><span class="br0">&#40;</span>jQuery<span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>1. ตรงนี้คือส่วนของการสร้าง plugin ที่มีชื่อว่า selectChain และมีค่า default ซึ่งสามารถ set ได้ เป็น<br />
key = ค่า key ที่ server จะคืนมา<br />
value = ค่า value ที่ server จะคืนมา<br />
ตรงนี้ ถ้าเราใช้ php ค่าที่จะต้องส่งคืนมาคือ</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;id&#8217;</span><span class="br0">&#93;</span> = <span class="nu0">1</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;value&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;Thailand&quot;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;id&#8217;</span><span class="br0">&#93;</span> = <span class="nu0">2</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="re0">$row</span><span class="br0">&#91;</span><span class="st0">&#8216;value&#8217;</span><span class="br0">&#93;</span> = <span class="st0">&quot;USA&quot;</span>;</div>
</li>
<li class="li2">
<div class="de2"><a href="http://www.php.net/echo"><span class="kw3">echo</span></a> json_encode<span class="br0">&#40;</span><span class="re0">$row</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">return</span> <span class="kw1">this</span>.<span class="me1">each</span><span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>2. ตรงนี้คือส่วนที่ จะจะค้นหา node ที่ match กับ ที่เราเรียกไว้ทั้งหมด</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">var</span> $$ = $<span class="br0">&#40;</span><span class="kw1">this</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>3. เอาตัวแปร $$ มาเก็บค่า this</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1"><span class="co1">// [No 1]</span></div>
</li>
<li class="li1">
<div class="de1">$$.<span class="me1">change</span><span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> data = <span class="kw2">null</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// [No 2]</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">typeof</span> settings.<span class="me1">data</span> == <span class="st0">&#8217;string&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data = settings.<span class="me1">data</span> + <span class="st0">&#8216;&amp;&#8217;</span> + <span class="kw1">this</span>.<span class="kw3">name</span> + <span class="st0">&#8216;=&#8217;</span> + $$.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span> <span class="kw1">else</span> <span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw1">typeof</span> settings.<span class="me1">data</span> == <span class="st0">&#8216;object&#8217;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data = settings.<span class="me1">data</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data<span class="br0">&#91;</span><span class="kw1">this</span>.<span class="kw3">name</span><span class="br0">&#93;</span> = $$.<span class="me1">val</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// [No 3]</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; settings.<span class="me1">target</span>.<span class="me1">empty</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// [No 4]</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span class="me1">ajax</span><span class="br0">&#40;</span><span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; url: settings.<span class="me1">url</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data: data,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: <span class="br0">&#40;</span>settings.<span class="me1">type</span> || <span class="st0">&#8216;get&#8217;</span><span class="br0">&#41;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataType: <span class="st0">&#8216;json&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; success: <span class="kw2">function</span> <span class="br0">&#40;</span>j<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw2">var</span> options = <span class="br0">&#91;</span><span class="br0">&#93;</span>, i = <span class="nu0">0</span>, o = <span class="kw2">null</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span>i = <span class="nu0">0</span>; i &lt; j.<span class="me1">length</span>; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; o = document.<span class="me1">createElement</span><span class="br0">&#40;</span><span class="st0">&quot;OPTION&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; o.<span class="me1">value</span> = <span class="kw1">typeof</span> j<span class="br0">&#91;</span>i<span class="br0">&#93;</span> == <span class="st0">&#8216;object&#8217;</span> ? j<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#91;</span>settings.<span class="me1">key</span><span class="br0">&#93;</span> : j<span class="br0">&#91;</span>i<span class="br0">&#93;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; o.<span class="me1">text</span> = <span class="kw1">typeof</span> j<span class="br0">&#91;</span>i<span class="br0">&#93;</span> == <span class="st0">&#8216;object&#8217;</span> ? j<span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#91;</span>settings.<span class="me1">value</span><span class="br0">&#93;</span> : j<span class="br0">&#91;</span>i<span class="br0">&#93;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; settings.<span class="me1">target</span>.<span class="me1">get</span><span class="br0">&#40;</span><span class="nu0">0</span><span class="br0">&#41;</span>.<span class="me1">options</span><span class="br0">&#91;</span>i<span class="br0">&#93;</span> = o;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// [No 5]</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setTimeout<span class="br0">&#40;</span><span class="kw2">function</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; settings.<span class="me1">target</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span class="me1">find</span><span class="br0">&#40;</span><span class="st0">&#8216;option:first&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span class="me1">attr</span><span class="br0">&#40;</span><span class="st0">&#8217;selected&#8217;</span>, <span class="st0">&#8217;selected&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span class="me1">parent</span><span class="br0">&#40;</span><span class="st0">&#8217;select&#8217;</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .<span class="me1">trigger</span><span class="br0">&#40;</span><span class="st0">&#8216;change&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>, <span class="nu0">0</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="co1">// [No 6]</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; error: <span class="kw2">function</span> <span class="br0">&#40;</span>xhr, desc, er<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">&quot;an error occurred&quot;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>ตรงนี้ขอ รวดเดียวจบเลยละกันครับ มันเกี่ยวเนื่องกัน เริ่มตั้งแต่ &#8230;.<br />
1. ถ้า มี event onchange gกิดขึ้นกับ element เมื่อไหร่ ให้ทำงาน<br />
2. จัดการกับค่าตัวแปร ที่จะถูกส่งให้กับ Server Side Script<br />
3. เคลียร์ค่า ให้กับ Target ที่ จะเอา option ไปใส่<br />
4. เริ่มส่งค่าให้ Ajax จากนั้นรับ Return ค่ารวมทั้ง สร้าง element options วนลูปค่าลงไป แล้วส่งให้ Element ที่เป็น target<br />
5. เรียกตัว target เพื่อทำการ add attribute <strong>selected</strong> ให้พร้อมทั้งส่ง Trigger ว่า Target ต้องทำ event onchange อีกที เพื่อตรวจสอบว่า select ตัวถัดไปต้องเปลี่ยนค่ามั้ย<br />
6. ทำการ Debug Error</p>
<p>วิธีใช้งานและตัวอย่างดูได้ที่เวบไซด์ เจ้าของ Plugin เลยครับ<br />
<a href="http://remysharp.com/2007/01/20/auto-populating-select-boxes-using-jquery-ajax/">http://remysharp.com/2007/01/20/auto-populating-select-boxes-using-jquery-ajax/</a></p>
<p>จบแล้วครับ สำหรับ บทความในวันนี้ ที่อยากจะให้เพื่อนๆ Focus กันก็คือคำสั่ง Trigger ครับ คำสั่งนี้เป็น ลักษณะ ของการจัดการ event ในรูปแบบ หนึ่งที่น่าสนใจทีเดียวครับ การทำงานก็จะเป็นการสร้าง trigger (อธิบาย ยากแฮะ) เช่น</p>
<p>เมื่อมีการ Click ที่ ปุ่มที่ 1 แต่ผมอยากจะให้ ปุ่มที่ 2 คลิกตามไปด้วย ผมก็จะใช้ Trigger นี่แหละครับ เป็นตัวบอก เช่นแบบนี้ครับ</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span><span class="st0">&#8216;#b2&#8242;</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">&#8216;I am B2&#8242;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li2">
<div class="de2">$<span class="br0">&#40;</span><span class="st0">&#8216;#b1&#8242;</span><span class="br0">&#41;</span>.<span class="me1">click</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">&#8216;I am B1&#8242;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span><span class="st0">&#8216;#b2&#8242;</span><span class="br0">&#41;</span>.<span class="me1">trigger</span><span class="br0">&#40;</span><span class="st0">&#8216;click&#8217;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2008/12/01/plugin-select-boxes-multilevel/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ทำ Preload Images ใน CSS สุดยอดแล้วโลกนี้</title>
		<link>http://www.jquerytips.com/2008/11/23/preload-css-images/</link>
		<comments>http://www.jquerytips.com/2008/11/23/preload-css-images/#comments</comments>
		<pubDate>Sat, 22 Nov 2008 18:50:24 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[preload]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=180</guid>
		<description><![CDATA[คงไม่มีใครปฎิเสธว่า ยุดนี้การเขียนเวบด้วย Stylesheet นั้นมาแรงเพียงไหน เวบเทพๆ ของโลกมองไปแทบจะไม่เจอ table เลยแม้สักตารางนิ้วเดียว เพราะว่าประโยชน์ของมันนั้น มีมากมาย ไม่ว่าจะเป็น การเข้าถึงที่รวดเร็ว, รองรับ SEO เต็มขั้น, อ้างอิง พาธ ได้ง่าย และอีกสารพัดจะ บรรยาย
วันนี้ผมเลยมี plugin ที่แสนวิเศษ จะมาแนะนำ&#8230;
คิดว่าหลายๆ คนที่เขียนเวบมาคงรู้จักกับคำว่า Preload Images นั้นก็คือการโหลด image ขึ้นมาเป็น bg process ในระหว่างที่ users กำลังนั่งอ่านข้อมูล เราก็โหลดถาพ ขึ้นมาพลางๆ เพื่อไม่ให้เป็นการเสียเวลา แต่ที่ผมจะมาแนะนำใน วันนี้ มันไม่ใช่! 
มันไม่ใช่การทำ Preload images แบบธรรมดา แต่มันคือการทำ Preload จาก external css ลองคิดดูกันเอาเองว่ามันจะวิเศษขนาดไหน
เท่าที่ไปลองแงะดู หลักการก็คือวิ่งเข้าไปหาไฟล์ .css จาก Doc เราจากนั้นมันก็จะวิ่งไปหา [...]]]></description>
			<content:encoded><![CDATA[<p>คงไม่มีใครปฎิเสธว่า ยุดนี้การเขียนเวบด้วย Stylesheet นั้นมาแรงเพียงไหน เวบเทพๆ ของโลกมองไปแทบจะไม่เจอ table เลยแม้สักตารางนิ้วเดียว เพราะว่าประโยชน์ของมันนั้น มีมากมาย ไม่ว่าจะเป็น การเข้าถึงที่รวดเร็ว, รองรับ SEO เต็มขั้น, อ้างอิง พาธ ได้ง่าย และอีกสารพัดจะ บรรยาย</p>
<p>วันนี้ผมเลยมี plugin ที่แสนวิเศษ จะมาแนะนำ&#8230;<span id="more-180"></span></p>
<p>คิดว่าหลายๆ คนที่เขียนเวบมาคงรู้จักกับคำว่า Preload Images นั้นก็คือการโหลด image ขึ้นมาเป็น bg process ในระหว่างที่ users กำลังนั่งอ่านข้อมูล เราก็โหลดถาพ ขึ้นมาพลางๆ เพื่อไม่ให้เป็นการเสียเวลา แต่ที่ผมจะมาแนะนำใน วันนี้ มันไม่ใช่! </p>
<p>มันไม่ใช่การทำ Preload images แบบธรรมดา แต่มันคือการทำ Preload จาก external css ลองคิดดูกันเอาเองว่ามันจะวิเศษขนาดไหน</p>
<p>เท่าที่ไปลองแงะดู หลักการก็คือวิ่งเข้าไปหาไฟล์ .css จาก Doc เราจากนั้นมันก็จะวิ่งไปหา นามสกุลไฟล์ gif|jpg|jpeg|png แล้วมาเข้าสู่ การทำ Preload ตามปกติ นั่นเองครับ ซึ่งเราไม่ต้องไปทำความเข้าใจมากมาย มาดูวิธีใช้อันแสนง่ายของมันเลยดีกว่า&#8230;</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span>document<span class="br0">&#41;</span>.<span class="me1">ready</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $.<span class="me1">preloadCssImages</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>เท่านี้จริงๆครับ ไม่ได้โกหก เพียงแค่ include jQuery กับตัว <a href="http://www.filamentgroup.com/examples/preloadImages/scripts/preloadCssImages.jQuery_v5.js">preloadCssImages</a> มาก็ใช้งานได้แล้ว</p>
<p>เอาล่ะครับ ถ้าสนใจหาข้อมูลเพิ่มเติมยังไง ไปดูกันได้ ที่นี่เลยครับ<br />
<a href="http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/">http://www.filamentgroup.com/lab/update_automatically_preload_images_from_css_with_jquery/</a></p>
<p>ของเค้าดีจริงๆ ไม่งั้นไม่เอามาแนะนให้เสียชื่อ jQurtyTips แน่ๆ ยังไงลองไปเล่นดูกันนะครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2008/11/23/preload-css-images/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Really Simple Validation</title>
		<link>http://www.jquerytips.com/2008/11/21/really-simple-validation/</link>
		<comments>http://www.jquerytips.com/2008/11/21/really-simple-validation/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 16:04:37 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[validate]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=173</guid>
		<description><![CDATA[หลายๆคนคงเคยเขียน validation ผ่าน js ซึ่งตามปกติแล้ว เรามักจะเขียน Rule ที่ละตัวๆ แล้วก็เขียนมันซ้ำไปซ้ำมาอยู่นั่นล่ะ เรียกว่าเป็นงาน Routine ที่น่าเบื่อสุดๆ ไปเลย ไหนจะ E-mail, ตัวเลข, ค่าว่าง, ภาษา, custom และอีกมากมายตามแต่จะรังสรรค์กันมา 
ถามหน่อยเหอะ &#8220;ไม่เบื่อเหรอ&#8221; ถ้าคำตอบว่า เบื่อ ลองมาดูการ validate ผ่าน jQuery plugin กันหน่อยเป็นไง ซึ่งตามที่ผมลองเล่นมา jQuery จะมี plugin ประเภทนี้ อยู่เพียบเลย แต่ผมให้แค่ 3 ตัว ก็คือ 
bassistance.de
- ตัวนี้ดีมากครับ ครบเครื่อง validate ได้ทุกรูปบบ ใช้ in-line code ได้ด้วย แต่ config ยากนิดนึง ต้องใช้เวลาในการทำความเข้าใจ
Consulenza-web.com
- ตัวนี้ใช้ง่ายที่สุดใน 3 [...]]]></description>
			<content:encoded><![CDATA[<p>หลายๆคนคงเคยเขียน validation ผ่าน js ซึ่งตามปกติแล้ว เรามักจะเขียน Rule ที่ละตัวๆ แล้วก็เขียนมันซ้ำไปซ้ำมาอยู่นั่นล่ะ เรียกว่าเป็นงาน Routine ที่น่าเบื่อสุดๆ ไปเลย ไหนจะ E-mail, ตัวเลข, ค่าว่าง, ภาษา, custom และอีกมากมายตามแต่จะรังสรรค์กันมา </p>
<p>ถามหน่อยเหอะ &#8220;ไม่เบื่อเหรอ&#8221; ถ้าคำตอบว่า เบื่อ ลองมาดูการ validate ผ่าน jQuery plugin กันหน่อยเป็นไง ซึ่งตามที่ผมลองเล่นมา jQuery จะมี plugin ประเภทนี้ อยู่เพียบเลย แต่ผมให้แค่ 3 ตัว ก็คือ <span id="more-173"></span></p>
<p><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/" target="_blank">bassistance.de</a><br />
- ตัวนี้ดีมากครับ ครบเครื่อง validate ได้ทุกรูปบบ ใช้ in-line code ได้ด้วย แต่ config ยากนิดนึง ต้องใช้เวลาในการทำความเข้าใจ</p>
<p><a href="http://www.consulenza-web.com/jquery_plugins/validation.html" target="_blank">Consulenza-web.com</a><br />
- ตัวนี้ใช้ง่ายที่สุดใน 3 ตัว ไม่ต้องศึกษาอะไรเลย แต่ข้อเสียคือ มันเป็นการ validation แบบ Type Watch คือ มันจะไม่มีตัวอะไรปรากฏ ถ้าเราทำการพิมพ์ไม่ถูกตาม Rule</p>
<p><a href="http://www.benjaminkeen.com/" target="_blank">Really Simple Validation (RSV)</a><br />
- ตัวนี้ค่อนข้างครบเครื่อง ใช้งานง่าย Custom Function ได้ แต่เสียดายที่มันมีการเขียนโคด แบบ in-line เราต้องระบุ Rule ให้ครบก่อน</p>
<p>*** รูปแบบการเขียน in-line คือระบุเข้าไปใน input ตรงๆ เช่น </p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;input id=&quot;cemail&quot; name=&quot;email&quot; class=&quot;{required:true, email:true, messages:{required:&#8217;Please enter your email address&#8217;, email:&#8217;Please enter a valid email address&#8217;}}&quot;/&gt;</div>
</li>
</ol>
</div>
<p>เอาล่ะๆ แต่ตัวที่จะมาพูดถึงวันนี้ก็คือตัวที่ 3 นั่น เอง ที่มีชื่อว่า <a href="http://www.benjaminkeen.com/" target="_blank">Really Simple Validation (RSV)</a> ซึ่งตัวนี้จะเป็น validation plugin ที่มีความสารถครบ ที่สำคญยังสารถ custom rule ได้เองอีก นับว่าเป็น plugin ที่มีประโยชน์ทีเดียว และเพื่อไม่ให้เกิดการ Duplicate Content เอาเป็นว่าไปดู Demo ที่เวบมันเอาเองเลยละกัน 555<br />
<a href="http://www.benjaminkeen.com/software/rsv/jquery/demo.php?page=1">Demostration Page</a></p>
<p>ซึ่งการใช้งานจะเป็นรูปแบบที่เราจะต้องทำการ Define Rules และ Messages เตรียมไว้ให้ input ก่อน ตัวอย่างเช่น (copy มา)</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span>document<span class="br0">&#41;</span>.<span class="me1">ready</span><span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; $<span class="br0">&#40;</span><span class="st0">&quot;#demo_form1&quot;</span><span class="br0">&#41;</span>.<span class="me1">RSV</span><span class="br0">&#40;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; onCompleteHandler: myOnComplete,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rules: <span class="br0">&#91;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;required,first_name,Please enter your first name.&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;required,last_name,Please enter your last name.&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;required,email,Please enter your email address.&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;valid_email,email,Please enter a valid email address.&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;required,any_integer,Please enter your age.&quot;</span>,</div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;digits_only,any_integer,The age field may only contain digits.&quot;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="st0">&quot;required,marital_status,Please enter your marital status.&quot;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#93;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
</ol>
</div>
<p>ซึ่งโดย default จะเป็นการ Alert ธรรมดาๆ แต่ถ้าอยากให้มัน Display มาที่หน้าแทนการ alert ก็แค่เพิ่ม option ไปไม่กี่ตัวเช่น</p>
<p>displayType: &#8220;display-html&#8221;<br />
errorFieldClass: &#8220;errorFieldDemo2&#8243;</p>
<p>จะเป็นระบุถึง DOM ตัวที่จะแสดง Error และยังสามารถกำหนด Class ให้มันได้อีกด้วย </p>
<p>โดยที่ตัวอย่าง Rules เราสามารถดูได้ที่หน้านี้<br />
<a href="http://www.benjaminkeen.com/software/rsv/jquery/demo.php?page=3" target="_blank">All Rules</a></p>
<p>รูปแบบก็คือ<br />
rules.push(&#8220;required,user_name,This field is required.&#8221;);<br />
1. Rule<br />
2. Input Field Name<br />
3. Message</p>
<p>การใช้งานก็ไม่ยากอะไร ยังไงถ้าสนใจก็ลองไป หาดาวน์โหลดมาใช้ได้จากลิ้งก์ที่ให้ไว้นะครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2008/11/21/really-simple-validation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>มาทำ Drag and Drop ในรูปแบบ Table กัน</title>
		<link>http://www.jquerytips.com/2008/11/21/table-drag-and-dro/</link>
		<comments>http://www.jquerytips.com/2008/11/21/table-drag-and-dro/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 15:26:41 +0000</pubDate>
		<dc:creator>Tee++;</dc:creator>
				<category><![CDATA[Plugins]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[drag]]></category>
		<category><![CDATA[drop]]></category>

		<guid isPermaLink="false">http://www.jquerytips.com/?p=171</guid>
		<description><![CDATA[หายไปนานเลย ช่วงนี้วุ่นๆ เพราะพึ่งย้ายงาน เลยต้องปรับตัว ไม่มีเวลามาอัพเดทเท่าไหร่ แต่วันนี้อากศหนาวเลยมา อัพเดทซะหน่อย 555+
ก็จะมาแนะน Plugin ดีๆ อีกตัวนึงของ jQuery เพื่อช่วยในการ Order ข้อมูลที่อยู่ในรูปแบบของ Table ซึ่งผมเห็นว่าน่าจะมีประโยชน์ในเรื่องของ การจัดลำดับของ ข้อมูลในส่วนของ Backend (ใครจะเอาไปใช้ Frontend ก็ได้) 
Plugin ตัวนี้ก็คือ Table Drag and Drop JQuery plugin โดยลักษณะตามโครงส้างของ HTML table จะประกอบไปด้วยหลักๆ ก็คือ 



&#60;table&#62;



&#60;tr&#62;



&#60;td&#62;&#60;/td&#62;



&#60;/tr&#62;



&#60;/table&#62;



และงานที่ plugin ตัวนี้จะทำให้เราก็คือการสลับตำแหน่ง tr นั่นเอง ไม่หมดแค่นั้น ตัว plugin เองเตรียม event มาให้เราครบเลย โดยจะประกอบไปด้วย 
onDragStart
onDragClass
onDrop
ทั้งยังสามารถกำหนดตำแหน่งที่จะทำให้เกิด Event ผ่าน function:
dragHandle
สุดท้ายก็คือทำกร Summary ข้อมูลผ่าน Function
$.tableDnD.serialize()
เอาล่ะอธิบายกันมาคร่าวๆ [...]]]></description>
			<content:encoded><![CDATA[<p>หายไปนานเลย ช่วงนี้วุ่นๆ เพราะพึ่งย้ายงาน เลยต้องปรับตัว ไม่มีเวลามาอัพเดทเท่าไหร่ แต่วันนี้อากศหนาวเลยมา อัพเดทซะหน่อย 555+</p>
<p>ก็จะมาแนะน Plugin ดีๆ อีกตัวนึงของ jQuery เพื่อช่วยในการ Order ข้อมูลที่อยู่ในรูปแบบของ Table ซึ่งผมเห็นว่าน่าจะมีประโยชน์ในเรื่องของ การจัดลำดับของ ข้อมูลในส่วนของ Backend (ใครจะเอาไปใช้ Frontend ก็ได้) </p>
<p>Plugin ตัวนี้ก็คือ <a href="http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/" target="_blank">Table Drag and Drop JQuery plugin</a> โดยลักษณะตามโครงส้างของ HTML table จะประกอบไปด้วยหลักๆ ก็คือ <span id="more-171"></span></p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;table&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;tr&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;td&gt;&lt;/td&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;/tr&gt;
</div>
</li>
<li class="li2">
<div class="de2">&lt;/table&gt;</div>
</li>
</ol>
</div>
<p>และงานที่ plugin ตัวนี้จะทำให้เราก็คือการสลับตำแหน่ง <strong>tr</strong> นั่นเอง ไม่หมดแค่นั้น ตัว plugin เองเตรียม event มาให้เราครบเลย โดยจะประกอบไปด้วย </p>
<p>onDragStart<br />
onDragClass<br />
onDrop</p>
<p>ทั้งยังสามารถกำหนดตำแหน่งที่จะทำให้เกิด Event ผ่าน function:</p>
<p>dragHandle</p>
<p>สุดท้ายก็คือทำกร Summary ข้อมูลผ่าน Function</p>
<p>$.tableDnD.serialize()</p>
<p>เอาล่ะอธิบายกันมาคร่าวๆ ละ ลองมาดูวิธีใช้งานจริงๆ กันดีกว่า&#8230;</p>
<p>โดยการใช้งานเราจะต้องกำหนดค่าให้กับ table ที่เราจะให้ทำงานก่อน และหลังจากนั้นก็ใช้คำสั่ง</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">$(&#8216;#table-1&#8242;).tableDnD();</div>
</li>
</ol>
</div>
<p>เท่านี้ Table ของคุณก็จะสลับตำแหน่งของ TR กันได้แล้ว โดยจะไม่สนว่าจะมี Child -> TD กี่ตัว</p>
<p>ทีนี้เราลองมาดูตัวอย่างการใช้งานจริงๆ เต็มรูปแบบของมันกัน</p>
<p>HTML Code</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&lt;table width=&quot;100%&quot; cellpadding=&quot;1&quot; cellspacing=&quot;1&quot; id=&quot;table-1&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;tr id=&quot;1&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &lt;td&gt;&lt;span class=&quot;handle&quot;&gt;Move&lt;/span&gt; Data&lt;/td&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;/tr&gt;
</div>
</li>
<li class="li2">
<div class="de2">&lt;tr id=&quot;2&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &lt;td&gt;&lt;span class=&quot;handle&quot;&gt;Move&lt;/span&gt; Data&lt;/td&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;/tr&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;tr id=&quot;3&quot;&gt;
</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &lt;td&gt;&lt;spanclass=&quot;handle&quot;&gt;Move&lt;/span&gt; Data&lt;/td&gt;
</div>
</li>
<li class="li2">
<div class="de2">&lt;/tr&gt;
</div>
</li>
<li class="li1">
<div class="de1">&lt;/table&gt;</div>
</li>
</ol>
</div>
<p>JS Code</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1">&lt;script type=<span class="st0">&quot;text/javascript&quot;</span>&gt;</div>
</li>
<li class="li1">
<div class="de1">$<span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span><span class="st0">&#8216;#table-1&#8242;</span><span class="br0">&#41;</span>.<span class="me1">tableDnD</span><span class="br0">&#40;</span><span class="br0">&#123;</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; dragHandle: <span class="st0">&#8216;handle&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; onDragClass: <span class="st0">&#8216;externalclass&#8217;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; onDragStart: <span class="kw2">function</span><span class="br0">&#40;</span>tb, row<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">// alert just testing or debugging</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="co1">//alert( &#8216;Dragging tr id &#8216; + row );</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; <span class="br0">&#125;</span>,</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; onDrop: <span class="kw2">function</span><span class="br0">&#40;</span>tb, row<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; <span class="kw2">var</span> order = $.<span class="me1">tableDnD</span>.<span class="me1">serialize</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; $.<span class="me1">post</span><span class="br0">&#40;</span><span class="st0">&#8217;saveorder.php&#8217;</span>, <span class="br0">&#123;</span> order: order <span class="br0">&#125;</span>, <span class="kw2">function</span><span class="br0">&#40;</span>str<span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; &nbsp; <span class="co1">// do something after save?</span></div>
</li>
<li class="li2">
<div class="de2">&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; <span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&lt;/script&gt;</div>
</li>
<li class="li2">
<div class="de2">&nbsp;</div>
</li>
</ol>
</div>
<p>เอาล่ะครับจากตัวอย่างที่ผมเขียน (ไม่ได้เทส เขียนสด Error เปล่าไปตรวจเอา) ก็คือผมสั่งให้ plugin ทำงานกับ table ที่มี id=table-1 </p>
<p>และจะสามารถ Drag ได้แค่ตำแหน่งที่ระบุ Class=handle จากนั้นเมื่อเริ่มทำการ Drag ให้ Node นั้นเรียก Class = externalClass ไปด้วย ซึ่งอาจจะเป็น class สำหรับการเปลี่ยนสี ให้มันดูเด่นหน่อยหรืออะไรก็ตาม แต่ โดยที่ class นี้จะทำงานแค่ระหว่างที่ทำการ Drag เท่านั้น </p>
<p>และเมื่อการ Drag เริ่มต้นจะให้มัน Alert อะไรหรือทำอะไรก็สั่งไปที่ onDragStart ในที่นี้ผมเขียนให้ไม่ทำอะไรทั้งนั้น</p>
<p>สุดท้ายสำคัญมากคือการ Drag จบจะให้ทำอะไร ในที่นี้ ผมสั่งให้ Summary ค่าออกมาโดยค่าที่ได้จะออกมาในลักษณะนี้</p>
<div class="dean_ch" style="white-space: wrap;">
<ol>
<li class="li1">
<div class="de1">table-1[]=1&amp;table-1[]=2&amp;table-1[]=3</div>
</li>
</ol>
</div>
<p>จะเห็นได้ว่า Format ที่ได้คือ Array นั่นเอง จากนั้นผมก็เรียก ajax แบบ post ส่งค่านี้ไปทันที และผมก็จะถอ array นี้ออกด้วย ภาษา PHP ด้วยคำสั่ง <strong>parse_str</strong> </p>
<p>จากนั้นก็เอาไป Re-order ใหม่ การทำงานก็จะจบลง เป็นไงล่ะครับ ง่ายมั้ย ถ้าสนใจยังไงลองไปดาวน์โหลดมาเล่นกันได้ที่<br />
<a href="http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/">http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/</a></p>
<p>คราวหน้าจะมาแนะนำของดีๆ ใหม่วันนี้พอแค่นี้ล่ะครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.jquerytips.com/2008/11/21/table-drag-and-dro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
