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
Saturday, December 26, 2015
Snipping tool missing in start menu in Windows 10
When you click start menu in Windows 10, in All apps, you may not find Snipping tool.
Snipping tool is in Windows 10, but just not shows up in start menu.
To use snipping tool, right click start menu, click Run in popup menu and type
snippingtool
snipping tool application will start to popup.
Friday, December 25, 2015
jQuery wildcard class, or name selector
You may need to click only via select only a class or name containing a string.
Jquery has wildcard class or name selector. For example
// handle elements like <div class="someclass1"></div>
$('[class^="someclass"]').click(function() {
// do stuff
});
// handle elements like <div class="foo someclass1"></div>
$('[class*=" someclass"]').click(function() {
// do stuff
});
Reference:
http://stackoverflow.com/questions/3697542/is-there-a-wildcard-class-selector
Thursday, December 24, 2015
jQuery click button events firing multiple times
I has jquery click event
$('.addRow_section').live('click', function(){
When the button is clicked, it is fired multiple times.
This is due to that the particular event is bound multiple times to the same element.
To fix this add die function:
$('.addRow_section').die("click");
$('.addRow_section').live('click', function(){
Reference:
http://stackoverflow.com/questions/14969960/jquery-click-events-firing-multiple-times
Tuesday, December 22, 2015
Jquery dynamically generated element (class, ID) click not working
For example
<script type="text/javascript">
$(document).ready(function() {
$(".div.ajax_list").click(function() {
$(".test").html("<button class='sendmail'>click me</button>")
});
$(".sendmail").on('click', function(){
alert('mail is sent');
});
});
</script>
You will find sendmail button did not work.change
$(".sendmail").on('click', function(){
alert('mail is sent');
});
to
$(".sendmail").live('click', function(){
alert('mail is sent');
});
will fix the problem.or
$(document).on('click','.sendmail00', function(){ alert('mail is sent'); });
Reference:
http://stackoverflow.com/questions/6658752/click-event-doesnt-work-on-dynamically-generated-elements
Tuesday, December 1, 2015
MySQL check valid email address
Check valid email address in MySQL:
emailaddresses.EmailAddress NOT REGEXP '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$')
Example
SELECT (CASE WHEN (emailaddresses.EmailAddress NOT REGEXP '^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$') AND stakeholders.ComputingID IS NOT NULL THEN
CONCAT(stakeholders.ComputingID, '@sfu.ca') ELSE emailaddresses.EmailAddress END) AS EmailAddress
FROM emailaddresses, stakeholders
WHERE emailaddresses.Stakeholder_id = stakeholders.Stakeholder_id
AND stakeholders.Stakeholder_id = 321 LIMIT 1;
Thursday, November 5, 2015
MySQLcase When Then END in comparison
Below is an example to use case When Then END in comparison in MySQL:
(CASE WHEN stakeholders.Action = 'New' AND stakeholders.InitialHireDate IS NOT NULL
AND stakeholders.InitialHireDate < (
CASE WHEN contract.SEApptStartDate IS NULL THEN terms_contract_lut.SEApptStartDate
ELSE contract.SEApptStartDate
END
) THEN 'REH' ELSE UPPER(stakeholders.Action)
END) AS Action,
(CASE WHEN stakeholders.Action = 'New' AND stakeholders.InitialHireDate IS NOT NULL
AND stakeholders.InitialHireDate < (
CASE WHEN contract.SEApptStartDate IS NULL THEN terms_contract_lut.SEApptStartDate
ELSE contract.SEApptStartDate
END
) THEN 'REH' ELSE UPPER(stakeholders.Action)
END) AS ActionReason,
Tuesday, November 3, 2015
Commas as thousands separators in number in Javascript
For example, we want to display 1000 as 1,000. JavaScript function
toLocaleString is used, example:n=1000;
m=n.toLocaleString();
m will be 1,000
If n is a string, we need to convert to number first
Number(n).toLocaleString();
toFixed(2) convert a number into a string, keeping only two decimals, we need to convert it to number when using toLocaleString()m = Number(n. toFixed(2)).
toLocaleString();
Saturday, October 31, 2015
Set CSS property in CodeIgniter helper
For example I want to add display:none in a button in CodeIgniter helper:
echo helper::generateHTMLButton('addPadRankButton', 'Add', array('disabled'=>'disabled', 'id'=>'','style'=>'display:none', 'class' => 'addPadRankButton'));
Using 'style'=>'display:none' in last parameter (array) of helper function to set CSS style.
Wednesday, September 2, 2015
jQuery, combine form serialize data with other variables
We use following for form data in post
$("div.ajax_list form#" + formName).serialize();
to add variables such as formName
var data0 = $("div.ajax_list form" + formName).serializeArray();
data0.push({name: 'formName', value: formName});
Complete example code:
function submitUpdateForm(formName){
var data0 = $("div.ajax_list form" + formName).serializeArray();
data0.push({name: 'formName', value: formName});
$.post('../../_ajaxParts/System/lut_termnew.php', data0, function(data) {
formatJson(data, '#notice');
submitFilterForm();
});
}
Monday, August 31, 2015
jQuery, save old select value and restore in dropdown menu
Use following in click function
$(this).attr('oldValue',$(this).val());
to store old select value in dropdown menu
Restore later in change function
var oldValue = $(this).attr('oldValue');
More code
$('div.ajax_list td.TaList select').live('click', function(){
$(this).attr('oldValue',$(this).val());
});
$('div.ajax_list td.TaList select').live('change', function(){
var row = $(this).parent().parent();
var oldValue = $(this).attr('oldValue');
var worksheet = $('select#viewWorksheet').val();
var section = row.find('td.TutSection input').val();
var ta = row.find('td.TaList select').val();
var startTime = row.find('td.StartTime select.StartHour').val()+':'+row.find('td.StartTime select.StartMinute').val()+' '+row.find('td.StartTime select.StartPeriod').val();
var endTime = row.find('td.EndTime select.EndHour').val()+':'+row.find('td.EndTime select.EndMinute').val()+' '+row.find('td.EndTime select.EndPeriod').val();
var Day = row.find('td.Day select').val();
var Room = row.find('td.Room input').val();
var enrolMax = row.find('td.EnrolMax input').val();
var tutorialID = row.find('td input.tutorialID').val();
var course_id = row.find('td input.course_id').val();
var courses_offered_id = row.find('td input.courses_offered_id').val();
var status = row.find('td.Status select').val();
var type = row.find('td.type').html();
var assign_id =row.find('td input.assignedID').val();
var assign_id0 = 0;
if (assign_id == '' || assign_id == null || assign_id==0) {
// assign_id =0;
// var d = new Date();
// assign_id0 = d.valueOf();
// row.find('td input.assignedID').val(assign_id0);
row.find('td input').prop('disabled', true);
}
$.post('../_ajaxParts/TA/SITAAssignment.php',
{funct:'updateSITA',
tutorialID:tutorialID,
course_id:course_id,
courses_offered_id:courses_offered_id,
section:section,
ta:ta,
taprev:ta1,
type:type,
assign_id:assign_id,
assign_id0:assign_id0,
day:Day,
startTime:startTime,
endTime:endTime,
room:Room,
enrolMax:enrolMax,
status:status}, function(data){
formatJson(data,"div#notice", function(json){
row.find('td input').prop('disabled', false);
if(json.data['NotAllowed']==1) {
alert('LTD not allowed for SI assignment');
row.find('td.TaList select').val(oldValue);
}else if(json.data['NotAllowed']==2) {
alert('Adjunct appoinment not allowed for SI assignment');
row.find('td.TaList select').val(oldValue);
}else if(json.data['NotAllowed']==3) {
alert('The assignment is not allowed due to related contract blocked.');
row.find('td.TaList select').val(oldValue);
}
else {
if (json.data['lastid'] != '' && json.data['lastid'] != null && json.data['lastid']!=0 &&json.data['status']=='Insert')
row.find('td input.assignedID').val(json.data['lastid']);
if(json.data['success']==1)
formatJson('{"success":"SI\/TA Info Updated."}', "div#notice", null);
else
formatJson(json.data, "div#notice", null);
}
});
});
});
Wednesday, July 1, 2015
jQuery, toggle the display
To change display none
row.find("td input.memo").css("display","none");
to display
row.find("td input.memo").css("display","block");
But this may case alignment distorted, it id better to use toggle
row.find("td input.memo").toggle();
Friday, June 26, 2015
CSS. draw a line in a box
This is the style to draw a line in left side a box:
1) Using box shadow:
box-shadow: inset -10px 0 5px -5px hsla(0,100%,50%,0.5);
2) Set a style in left side of the box:
border-left-width: 5px;
border-left-style: solid;
border-left-color: #B27F4C;
MySQL NULL column during comparison
In MySQL table, I have column WorkPermit, 5 values, 'N', 'N', 'N', NULL, NULL
When we do MySQl statement WorkPermit !=N, we expect to get 2, but result return nothing
as NULL not participate comparision in not equal.
So when we use != (not equal) in MySQL, we should add condition
( WorkPermit !=N or WorkPermit IS NULL)
Wednesday, June 24, 2015
json_encode data in php to javascript
I have a function in php
function GetROFRpl($arr){
$arr['coursename'] = preg_replace('/\s+/', '', $arr['coursename']);
$c = new Connection();
$sql0 = "SELECT * FROM rofr_parental_leave WHERE stakeholder_id = {$this->sanitizeInput($arr['sid'])}
AND coursename = {$this->sanitizeInput($arr['coursename'])} ";
$result = $c->query($sql0);
while($row = $c->getArray($result)){
$data[$row['id']] = $row;
}
return $data;
}
which is called by another function and data format to json_encode
function GetROFRpl($arr){
$model = new TeachingContract();
$data = $model->GetROFRpl($arr);
$arrayForJSON = array("count" => count($data), "data" => $data);
echo json_encode( $arrayForJSON );
}
In javascript, I used JSON.parse to parse data to Javascript array
$('.pl').on('click', function(){
var row=$(this).parents('tr');
var sid=row.find('.sid').attr('data-sid');
var coursename=row.find('.coursename').html();
pldate= "Parental Leave:<table id='pl_table'><tbody>";
var postdata = {funct: 'GetROFRpl', sid:sid, coursename:coursename};
var url = '../_ajaxParts/ROFR/SITAROFR_list.php';
$.post(url, postdata, function(data) {
var dataarray = JSON.parse(data);
var dataarray0 = dataarray['data'];
for(var key in dataarray0) {
var getrow = "<tr class='worksheet' data-id='"+dataarray0[key]['id']+"'><td class='delete' ><span class='btn glyphicon glyphicon-trash'></span></td><td>Start date: <input type='text' class='hasDatepicker pl_start_date' placeholder='yyyy-mm-dd' name='pl_start_date' value='"+dataarray0[key]['startdate']+"'></td><td>End date: <input type='text' class='hasDatepicker pl_end_date' placeholder='yyyy-mm-dd' name='pl_end_date' value='"+dataarray0[key]['enddate']+"'></td></tr>";
pldate = pldate +getrow;
}
pldate0= "<tr class='template' data-id=''><td class='delete' ><span class='btn glyphicon glyphicon-trash'></span></td><td>Start date: <input type='text' class='hasDatepicker pl_start_date' placeholder='yyyy-mm-dd' name='pl_start_date'></td><td>End date: <input type='text' class='hasDatepicker pl_end_date' placeholder='yyyy-mm-dd' name='pl_end_date'></td></tr>";
pldate = pldate +pldate0+ '</tbody></table><br /><div class="addRow btn btn-primary">Add Row</div>';
});
Sunday, June 21, 2015
Bootstrap Datepicker on change firing twice or three times
I used Bootstrap Datepicker
$('.hasDatepicker').on('change', function(){
});
Bootstrap Datepicker fired three times. After I change it to
$('.hasDatepicker').datepicker().on('change', function(){
});
Bootstrap Datepicker fired twice.
Solution 1
change
$('#ROFRmail .modal-body .hasDatepicker').datepicker({ minDate: 0}).on('change', function(){
to
$('#ROFRmail .modal-body').on('change', '.hasDatepicker', function(){
As when I add row, I did not have .hasDatepicker row.
Solution 2
Get global variable count and check if equal to 0 then execute Your function.
My code: use count=0 in .post to wait for ajax post post feedback to update id in div for next postvar count=0;
$( "#Id" ).datepicker({ minDate: 0}).on('change',function (){
if(count==0)
validity();//any function
count=1;
});
validity(){ count=0;}
$('#ROFRmail .modal-body .hasDatepicker').datepicker({ minDate: 0}).on('change', function(){
var row1=$(this).parents('tr');
var pl_id = row1.attr('data-id');
var startdate = row1.find('.pl_start_date').val();
var enddate = row1.find('.pl_end_date').val();
$(this).attr('disabled','disabled');
var postdata = {funct: 'UpdateROFRpl', pl_id:pl_id,sid:sid, coursename:coursename, startdate:startdate,enddate:enddate};
var url = '../_ajaxParts/ROFR/SITAROFR_list.php';
if(count==0){
$.post(url, postdata, function(data) {
row1.attr('data-id',data);
count =0;
row1.find('.hasDatepicker').removeAttr('disabled');
});
}
count=1;
});
Friday, June 19, 2015
A script on this page may be busy firefox jquery
In Firefox, when I loaded a page, it showed ""A script on this page may be busy, or it may have stopped responding. You can stop the script now, or you can continue to see if the script will complete." I need to click continue or stop. To fix this unresponsive script:
1) In the address bar, type about:config and press Enter.
about:config
2) Click I'll be careful, I promise! to continue to the about:config page.
3) search for the preference dom.max_script_run_time, and double-click on it. In the Enter integer value prompt,
change 10 to 40.
4) Press OK.
Wednesday, June 17, 2015
JavaScript, simple alert dialog callback
In java Script, when we create alert box and click OK, we hope some actions are performed.
The Modal dialog box, jquery dialog box and bootbox dialog box have similar features.
But the following codes are simplest:
for example, a table with a column with delete icon:
<tr class='template'><td class='delete' ><span class='btn glyphicon glyphicon-trash'></span></td></tr>
After clicking delete ico, this row is deleted after click ok in alert box:
$('td.delete').on('click', function(){
var answer = confirm("Are you sure to delete this row?");
if (answer)
$(this).parents('tr').remove();
});
Tuesday, June 16, 2015
Pass data via attribute in JavaScript
We create a data attribute sid (you can change to any name) and assign it value 3456
<tr><td class='sid' id='firstname' data-sid='3456'></td> </tr>
Below is the script to click this cell to display this value using jQuery:
$('.sid').on('click', function(){
var $tr = $(this).parents('tr');
var sid = $tr.find('#firstname').attr('data-sid');
alert(sid);
});
Monday, June 15, 2015
JavaScript email validation
JavaScript regular email validation:
function validateRegularEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
return regex.test(email);
}
JavaScript gmail validation:
function validateGmail(email) {
//Gmail required: %@gamil.com
var re = /^\s*[\w\-\+_]+(\.[\w\-\+_]+)*\@[\w\-\+_]+\.[\w\-\+_]+(\.[\w\-\+_]+)*\s*$/;
if (re.test(email)) {
if (email.indexOf('@gmail.com', email.length - '@gmail.com'.length) !== -1) {
return true;
} else {
bootbox.alert('Please enter Gmailaddress.');
}
} else {
bootbox.alert('Please enter Gmail address.');
}
}
To use this function:
testmail ='test@htomail.com';
if(!validateRegularEmail(testmail)) alert('Wrong email adress');
JavaScript: add days to current date
Below is JavaScript: to add days to current date:
var someDate = new Date();
//11 days are added in current date
someDate.setDate(someDate.getDate() + 11);
var dateFormated = someDate.toDateString();
alert(dateFormated);
The result will be like
Fri June 26 2015
Creating multiline strings in JavaScript
For a long strings, if you use return key in text editor for javascript, you may encounter an error for example:
var s1= 'test
This is another line';
We can use \ in at the end of each line to create a multiline string such as
var s1= 'test \
This is another line';
We can also use string concatenation (better)
var s1= 'test'+
'This is another line';
Rendering HTML tags inside textarea
In textarea
var $mailform = $('<textarea id="textbody"><textarea>');
$mailform.find('#textbody').html("Dear <br />, This is advised that...");
We found html tags br is not rendered.
To sovle this problem, we make a div editable
var $mailform = $('<div id="textbody" class="editable"><div>');
$mailform.find('#textbody').html("Dear <br />, This is advised that...");
$('.editable').each(function(){
this.contentEditable = true;
});
Now this div has same feature as textarea.
Sunday, June 14, 2015
Javascrpt dialog box using bootbox
Bootbox.js is a small JavaScript library which allows you to create programmatic dialog boxes using Bootstrap modals
Bootbox.js can be downloaded from:
http://bootboxjs.com/
Example of bootbox to creat cancel and OK dialog button
<script type='text/javascript' id='' src='bootstrap.min.js'></script><script type='text/javascript' id='' src='bootbox.min.js'></script>
bootbox.dialog({
message: "Are you sure you want to send out ROFR?",
buttons: {
cancel: {
label: "Cancel",
className: "btn-default btn-sm",
callback: function() {
// $('#mail').modal('show');
}
},
OK: {
label: "OK",
className: "btn-warning btn-sm",
callback: function() {
var postdata = {};
var url = ' ';
$.post(url, postdata, function(data) {
$("div#notice").html('mail is sent.');
$("div#notice").css('display', 'block');
$("div#notice").fadeOut(5000);
});
}
},
}
});
Install, Start / Stop / Restart Postfix Mail Server in Linux
You can install postfix mail server in Linux using yum:
sudo yum -y install postfix
Postfix mail config file /etc/postfix/main.cfTo Start / Stop / Restart Postfix Mail Server in Linux: sudo service postfix start
sudo service postfix stop
sudo service postfix restart
To cehck if postfix is tarted:sudo postfix status
You will get the following message it it is tarted:
postfix/postfix-script: the Postfix mail system is running: PID: 2357
Linux mail command prompt help
mail is a simple email client command line in Linux.
Type mail in shell
h
list all email with only headers, this is also the way to go back main menu
z to next screen.
type number to read message
type h to return to main menu
? for help
list to list command
Mail Command Description
------------------------- --------------------------------------------
t [message list] type message(s).
n goto and type next message.
e [message list] edit message(s).
f [message list] give head lines of messages.
d [message list] delete message(s).
s [message list] <file> append message(s) to file.
u [message list] undelete message(s).
R [message list] reply to message sender(s).
r [message list] reply to message sender(s) and all recipients.
p [message list] print message list.
pre [message list] make messages go back to /var/mail.
m <recipient list> mail to specific recipient(s).
q quit, saving unresolved messages in mbox.
x quit, do not remove system mailbox.
h print out active message headers.
! shell escape.
| [msglist] command pipe message(s) to shell command.
pi [msglist] command pipe message(s) to shell command.
cd [directory] chdir to directory or home if none given
fi <file> switch to file (%=system inbox, %user=user's
system inbox). + searches in your folder
directory for the file.
set variable[=value] set Mail variable.
Wednesday, June 10, 2015
Parse JSON in JavaScript
In PHP, I used
$message['success'] = "Personal Information Updated";
echo json_encode($message);
to pass $message to Javascript .post
$.post('stakeholderInfo.php', $(".box#stakeholderInfo div #editInfoForm").serialize(), function(jsonMessage) {
obj = JSON.parse(jsonMessage);
alert(obj['success']);
});
Here I used JSON.parse to parse JSON in JavaScript, then display message alert(obj['success']);
Friday, June 5, 2015
increase mysql query speed
If want to increase mysql query speed, you need to create a primary key for your table, and also add the columns you want to search as index.
Tuesday, June 2, 2015
PHPExcel keep leading 0s in number
In EXCEL columns from PHPExcel, I want to display number 2 as 0002.
After setting the cell value,
For cell F1:
$objPHPExcel->getActiveSheet()->getStyle('F1')
->getNumberFormat()->setFormatCode('0000');
For cell F1 to F1000:$objPHPExcel->getActiveSheet()->getStyle('F1:F1000')
->getNumberFormat()->setFormatCode('0000');
To get all columns align left
$objPHPExcel->getActiveSheet()->getDefaultStyle()
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
For cell F1 to F1000 align left:
$objPHPExcel->getActiveSheet()->getStyle('F1:F1000')
->getAlignment()
->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
Friday, May 29, 2015
Update Linux servers
Recommend once per month to update Linux web servers:
sudo yum check-update
sudo yum update
to reboot
sudo shutdown -r now
autocomplete in notepad++
Auto-Completion in notepad++ is enabled by a checkbox via settings in Settings -> Preferences -> Auto-Completion. You accept the suggestion by typing Enter or Tab. you can use the Down- & Up-arrow keys, or PageDown & PageUp, to move through the list; or, type Esc to dismiss the list.
Tuesday, May 26, 2015
Freeze submit button when waiting ajax post data
When we update a input box from ajax post, it may delay. When users click the submit button, the old data will be posted. We need to freeze submit button when waiting ajax post data.
Example:
$('#universalModal .modal-body input[name="StudentID"]').val(Obj.student_num);
$('#universalModal .modal-footer button#submitBtn').html('Save and Exit');
$('#universalModal .modal-footer button#submitBtn').prop("disabled", true);
$.post(url, postdata, function(data){
$("input[name='StudentID']").val(null);
$('#universalModal .modal-footer button#submitBtn').prop("disabled", false);
}
});
When the submit button is enables and we click submit button, the StudentID value is update from ajax post. Now we can post all form data vi submit.
Difference between set empty and set null in jquery input value
I posted form data in Modal form using $('form#populate').serializeArray().
I manually set an input text box empty
$("input[name='StudentID']").val(' ');
But when I use PHP empty function, the post data from StudentID is not empty. I used Network in web developer tools in Firefox and see the post data is "+". (Although finally it will transfer to empty string)
Finally I set it as null
$("input[name='StudentID']").val(null);
The post.data is " " in web tools and make empty function judges correctly.
Saturday, May 23, 2015
Trigger a click in jQuery
To trigger a click in jQuery, for example id stakeholderAccesses:
$('#stakeholderAccesses').click();
I found following trigger function not working well:
$('#stakeholderAccesses').trigger('click');
Complete example:
$(document).ready(function() {
//Display and Load the body part when the header is clicked.
$('#stakeholderAccesses').click(function() {
if( $(this).parent().children('div').css("display") == "none" ) {
$(this).html( '-' + $(this).html().substring(1) );
$(this).parent().children('div').load('../_ajaxParts/CVS/CVS_Access.php', {sid: $.url.param('sid')}).show('fast');
}
else {
$(this).html( '+' + $(this).html().substring(1) );
$(this).parent().children('div').hide('fast');
}
}).hover(function() {$(this).css('cursor','pointer');},function() {$(this).css('cursor','auto');});
$('#stakeholderAccesses').click();
});
Sunday, March 29, 2015
Git merge conflict using git mergetool
When you pull changes from the Git server you might get conflict in your code.
sudo git fetch origin
sudo git merge origin/master
So we will see how to resolve those conflicts. You can use git mergetool to check the conflicts. This is the merge conflict resolution tools to resolve merge conflicts.
git mergetool
- git checkout --ours <your File name>
- git checkout --theirs <your File name>
- git add <your File name>
- git commit -m "Conflicts Resolve"
(here remote is origin, local is master)
Note Difference between pull and fetch
n the simplest terms,
git pull does a git fetch followed by a git merge.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)