jQuery Ajax – send all fields data by “POST”
jQuery Ajax – send all fields data by “POST” jQuery.ajax({ data: jQuery(‘#formId’).serialize(), // etc.. }
JavaScript Programming
jQuery Ajax – send all fields data by “POST” jQuery.ajax({ data: jQuery(‘#formId’).serialize(), // etc.. }
Print array elements with javascript: var output = ”; for(var i=0; i < arr.length; i++){ output += "arr[" + i + "] = " +…
The syntax of the window.open: open (URL, windowName[, windowFeatures]) example: window.open (“http://www.g31zone.com”,”G31zone”); window.open (“http://www.g31zone.com”, “G31zone”,”status=1,toolbar=1″); Parameters: status The status bar at the bottom of the…
Verify if a checkbox is selected (checked) with jQuery <form name=”my_form_name” id=”my_check_box”> <input type=”checkbox” name=”my_check_box” id=”my_check_box”> </form> <script type=”text/javascript”> jQuery(document).ready(function() { jQuery(‘#my_check_box’).click(function () { if…
Method to prevent form submitting using jQuery: <form method=”post” name=”my_form_name” id=”my_form_id”> <input type=”submit” value=”Go”> </form> <script type=”text/javascript”> jQuery(‘#my_form_id’).submit(function() { alert(‘Prevent form submitting.’); return false; });…
Javascript – limit the number of characters in a textarea: <script language=”javascript” type=”text/javascript”> function limitText(fieldLimit, countLimit, limitNum) { if (fieldLimit.value.length > limitNum) { fieldLimit.value =…
A Javascript function for add slashes: function addslashes(str) { str=str.replace(/\\/g,’\\\\’); str=str.replace(/\’/g,’\\\”); str=str.replace(/\”/g,’\\”‘); str=str.replace(/\0/g,’\\0’); return str; } A Javascript function for strip slashes: function stripslashes(str) {…
Javascript function to redirect to another page after 5 seconds: function redirect_after_5_seconds() { setTimeout(“location.href=’index.php/new_url_for_redirection'”, 5000); }
Create a link to go back to the last page opened: <a href=”javascript: history.go(-1);” >Back </a>
Compare two dates in Javascript: <html> <head> <title>JavaScript – compare two dates</title> </head> <body> <script language=”Javascript” type=”text/javascript”> var date1 = new Date(“22/12/2010”); var date2 =…