Category: Javascript & Jquery
-
Auto save form using PHP, jQuery
This blog is regarding how to auto save form using PHP, jQuery. There are many tutorial available but it is very simple method. HTML Form : <form id=”auto-save-form”> Name : <input name=”name” type=”text” /> Email : <input name=”email” type=”text”> <input name=”submit” type=”submit”/> </form> JQuery Code: /*Form Auto Submit Logic*/ var changeFlag = false; var focusFlag…
-
printing webpage without opening new window using jQuery
Print is a create a big problem to mostly developers (I’m one of them). The problem like “print without opening new window”. Today, in this post I write a solutions of same problem. The solutions is : Use Jquery/Javascript with iframe elements. Small code for solution is below. var theUrl=”print.html”; $(“<iframe>”) // create a new…
-
Rotate Image using Jquery & PHP
Many Library available for rotating the image object. But, here we are rotating the image object using Jquery, Ajax and PHP. Here using PHP GD library for rotating the image object. There are many options to rotate the image object. But, here we using simple method. Note: In this example We used jpeg format Image.…
-
how to check browser window visibility using jquery
Whenever you switch the browser or tab then execute some events. Below is html & jquery code to check your browser window visibility Using this code : Check the title bar when you are switch the browser or tab. If title bar display “Active” it means you are on current tab or browser If title…
-
how to use json in php?
//test.php <script type=”text/javascript” src=”http://code.jquery.com/jquery-2.1.0.min.js”></script> <input type=”button” name=”show” id=”show” value=”Click TO Show Data ” /> <br> Json Encode Data : <div id=”json_output” style=”border:#000 1px solid;width:337px;height:337px;overflow:auto”> </div> Json Output Data of output variable : <div id=”json_output_variable” style=”border:#000 1px solid;width:337px;height:337px;overflow:auto”> </div> <script type=”text/javascript”> $(“#show”).click(function (){ var datastr=’format=json&id=37′; $.ajax({ type:’POST’, data:datastr, url:’json.php’, success:function(html) { $(“#json_output”).html(html); var obj=JSON.parse(html);//decode the json…
-
how to get multiple select values in javascript
//Here client is id of multiple dropdown…. <select multiple=”multiple” id=”client” > <option value=’1′>1</option> <option value=’2′>2</option> <option value=’3′>3</option> </select> <input type=’button’ value=’Test’ onclick=’tes()’> <script type=’text/javascript’> function tes() { var cnt=document.getElementById(‘client’).length; var arr=new Array(); var j=0; for(var i=0;i<cnt;i++) { if(document.getElementById(“client”).options[i].selected == true) { …
-
how to Change browser url without page reloading with ajax request using JavaScript, HTML5 history API, jQuery, PHP like Facebook, Github navigation menu?
Consider a page that has the following links to three menu items and a div to display the ajax content. <div id=”menu”> <a href=”m1.php” rel=”tab”>menu1</a> | <a href=”m2.php” rel=”tab”>menu2</a> | <a href=”m3.php” rel=”tab”>menu3</a> </div> To override the default action for the link(anchor tag), use the following jQuery code snippet. $(function(){ $(“a[rel=’tab’]”).click(function(e){ //code for the link…
-
how to refresh particular div tag content without reloading page using jquery?
// Note : First include jquery.js file….. <script type=”text/javascript”> var auto_refresh = setInterval( function () { $(‘#load_div’).load(‘load.php’).fadeIn(“slow”); }, 100000); // refresh every 10000 milliseconds </script> //index.php <div id=”load_div”> </div> //load.php In this page you can write your code. like load randam user,image etc….
-
How to pass data from one domain to another domain(cross domain) using json?
//Javascript code <script type=”text/javascript”> $(document).ready(function() { var surl = “http://www.example.com/json.php”; email_id=document.getElementById(“email”).value; $.ajax({ url: surl, data: {email:email_id}, dataType: “jsonp”, jsonp : “callback”, jsonpCallback: “jsonpcallback” }); }); function jsonpcallback(rtndata) { document.getElementById(“disp_data”).innerHTML=rtndata.message; } </script> //json.php file code <?php $display=”<b>HI Json</b>”; $display.=”<p>HI This is testing json.</p>”; $rtnjsonobj->message = $display; echo $_GET[‘callback’]. ‘(‘. json_encode($rtnjsonobj) . ‘)’; ?>
-
how to check element visibility in jquery?
example of element exists and it’s not visible <div id=”test”> <div id=”test_1″ style=”display:none”> Hello World! </div> </div> jQuery code: if ($(‘#test_1:visible’).length > 0) { alert(‘the element is visible’); } else { alert(‘the element is not visible’); }