Archive

Archive for the ‘Jquery’ Category

PHP function to javascript

June 26, 2012 Leave a comment

php function ที่แปลงไปเป็น ภาษา js
http://phpjs.org/

Categories: Jquery, PHP Tags: ,

[Javascript] Unixtime to Datetime and Datetime to Unixtime

October 14, 2011 Leave a comment

// อันนี้ Date Time => Unixtime
var d = Date.parse(“10/15/2011 02:00:00”);
// format ในตัวอย่างเป็น mm/dd/yyyy hh:ii:ss
เอาค่า d หาร 1000 ได้เท่ากับ Unix time บน MySQL เพราะ Java เก็บเป็นมิลลิวินาที
กรณีเอา Unixtime บน MySQL ก็ต้องเอามาคูณ 1000 ก่อนเหมือนกัน ก่อนนำมาใช้

// หา Date Month Year วันที่ โดย unixtime อย่าลืม 000 ที่เปนมิลลิวินาที

// ข้างล่างเป็น Unixtime => Date Time
// Date
var d=new Date(1318791600000);
document.write(d.getDate(1318791600000));
// return 17 [1-31]

// Month
var d=new Date(1318791600000);
document.write(d.getMonth(1318791600000)+1);
// return 10 ต้องบวก 1 เพราะ มัน 0-11 [0-11]

var d=new Date(1318791600000);
document.write(d.getFullYear(1318791600000));
// return 2011 [four digits]

var d=new Date(1318791600000);
document.write(d.getHours(1318791600000));
// return 2 [0-23]

var d=new Date(1318791600000);
document.write(d.getMinutes(1318791600000));
// return 0 [0-59]

นี่เป็นตัวอย่างฟังก์ชั่นง่าย ๆ ของ Javascript เกี่ยวกับ Date Time
ข้อมูลเพิ่มเติม http://www.w3schools.com/jsref/jsref_obj_date.asp

Categories: Jquery Tags: , , ,

วิธีเข้าถึง Tab Jquery โดย Url ตรง

August 16, 2011 Leave a comment

Code ตัวอย่าง

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
  // initialize tabs
  var $tabs = $("#tabs").tabs();

  $tabs.tabs('select', document.location.hash+"_x");

  $("#tabs").bind('tabsshow', function(event, ui){
        document.location.hash = ui.panel.id.replace("_x","");
    });
});
</script>

<div id="tabs">
  <ul>
      <li><a href="#tab1_x"><span>Tab 1</span></a></li>
      <li><a href="#tab2_x"><span>Tab 2</span></a></li>
      <li><a href="#tab3_x"><span>Tab 3</span></a></li>
  </ul>
  <div id="tab1_x">[content 1 ]</div>
  <div id="tab2_x">[content 2 ]</div>
  <div id="tab3_x">[content 3 ]</div>
</div>

หลังจากนั้นลองคลิกเพื่อ Url ที่เปลี่ยน คุณสามารถนำ Url นั้นมาเข้า Tab ได้โดยตรงเลย

Categories: Jquery Tags: , ,