Adsense
Popular Posts
- Amazon web serive
- MySQL workbench -"Could not decrypt password cache"
- git svn conversion
- increase mysql query speed
- Unix Utils and wget in Windows
- add comment to table columns in phpMyAdmin
- Special characters pronunciation link
- deposit cheque in TD bank using Mobile phone
- Setup vi syntax for PHP
- Get WAMP running on EC2
Sunday, February 15, 2015
JavaScript date format to MySQL date format
MySQL date format:
2015-04-24
To get JavaScript date format the same as MySQL date format:
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
if(dd<10){
dd='0'+dd
}
if(mm<10){
mm='0'+mm
}
var today = yyyy+'-'+mm+'-'+dd;
jQuery prepend and append method
The prepend() method inserts specified content at the beginning of the selected elements
and append method is to insert content at the end of the selected elements.
Example
$blockAll = $(" <input type='button' class='block all' value='Block All Salary \> 0' />");
$("div.ajax_list").prepend($blockAll);
$viewAllPdf = $("<input type='button' class='viewallpdf' value='Preview All Contracts with Salary \> 0 (May take up to 5 minutes)' />");
$("div.ajax_list").prepend($viewAllPdf);
The button viewallpdf will come first and blockall button comes after.
Thursday, February 12, 2015
MySQL query SELECT IN using PHP array
MySQL query SELECT IN using PHP array
integers:
$query = "SELECT * FROM `$table` WHERE `$column` IN(".implode(',',$array).")";
strings:$query = "SELECT * FROM `$table` WHERE `$column` IN('".implode("','",$array)."')";
Wednesday, February 4, 2015
JavaScript, remove trailing insignificant zeros after toFixed function
In JavaScript, toFixed function is used to convert a number into a string, keeping only two decimals:
For example
var num = 6.76789;
var n = num.toFixed(2);
return 6.77
var num = 6;
var n = num.toFixed(2);
return 6.00
But How to remove trailing insignificant zeros?
We can use Number function or parseFloat function such as
Number(num.toFixed(4));
or
parseFloat(num.toFixed(4));
Tuesday, February 3, 2015
Click save button, parent window refresh using JavaScript
open a window in new tab in firefox:
window.open('SITAview_form.php?sid=' + stakeholder_id + '&term=' + term + '&cid=' + course_id+'&pad_id=' + pad_id);
Now I want to refresh parent window when click save button in this window:, window.opener.location.reload(); is used to reload parent window in JS:
$('div.box#Contract_basic_Info input.saveButton').click(function() {
saveBasicInfo();
window.opener.location.reload();
});
Subscribe to:
Posts (Atom)