Posts

Geo Location - Get location based on where you are

Hi, Today i am going to share script how to get location based on where you are located.  Here is the script, <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>GMap location</title> <script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.min.js"> </script> <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script> <script> $(document).ready(function() {  navigator.geolocation.getCurrentPosition(function (pos) {     var geocoder = new google.maps.Geocoder();     var lat = pos.coords.latitude;     var lng = pos.coords.longitude;     var latlng = new google.maps.LatLng(lat, lng);      //reverse geocode the coordinates, returning location information.     geocoder.geocode({ 'latLng': latlng }, function (results, st...

Javascript function to display 2 digit number

Hi, Today i am going to share how to display 2 digit number in javascript and jQuery, Javascript: ------------- function twodigit(num) {          var num1 = parseInt(num, 10);           return num1 < 10 ? "0" + num1 : num1;     } JQuery: --------- $('#count').text(function(i,num) {   var num1 = parseInt(num, 10);   return num1 < 10 ? "0" + num1 : num1; }); Output: ---------- twodigit(1); // returns 01 twodigit(2); // returns 02

Upload folder for images

Image
Here i am going to explain how to upload folder instead of files. For that we need to add  webkitdirectory=""  inside the input tag in HTML For eg, <input type="file" name="file_input[]" id="file_input" multiple="" webkitdirectory=""> Output:

GMap Location Pointer based on Longitude and Latitude

Image
In this post, i am going to share how to display gmap pointer based on longitude and latitude. Here is the code, <!DOCTYPE html> <html> <head>   <meta http-equiv="content-type" content="text/html; charset=UTF-8">   <title> GMap location </title>   <script type='text/javascript' src="http://maps.google.com/maps/api/js?sensor=false&.js"></script>   <style type='text/css'>     #map_canvas{         width: 600px;         height: 500px;     }   </style>   </head> <body> <div id="map_canvas"></div> <script type='text/javascript'>//<![CDATA[ var map; var global_markers = [];    var markers = [[37.09024, -95.712891, 'trialhead0'], [-14.235004, -51.92528, 'trialhead1'], [-38.416097, -63.616672, 'trialhead2']]; var infowindow = new google.map...

Array to JSON

To display array values in JSON format, you need to use json_encode(). For eg: $arr = array('username' => 'test','userid' =>'1', 'password' => 'test123'); // Use json_encode to return in json format echo json_encode($arr); Output: {"username":"sham dhar","userid":"36","password":"test123"}

Trigger event on Hiding modal box

Some of the peoples will be using this for Bootstrap3 to hide modal box. Some may be facing issues on using this function, $('#myModal').on('hidden.bs.modal', function () {    alert("hii"); }); So, here is the solution for all who are all facing issues, This function will work in all the browsers where as, the above function will not work in some browsers such as chrome, etc. $('#myModal  button').click(function () {     $('#myModal iframe').removeAttr('src'); });

Breezing forms - Get datas from database

Copy the below code in your breezing forms by selecting your form, Go to Advanced -> More options -> Select "Form scripts" -> After Form or Before form its up to your requirement. // load the standard form creation utilities $this->execPieceByName('ff_InitLib'); //set globals global $record; //query db  $rows = ff_select("select * from `#__users`"); $html = ''; foreach ($rows as $row) $html .= "<div style='display:block'> <input type='text' name='$row->user_id' id= '$row->user_id' value='$row->user_id' />  </div>"; return $html; It will return all the values from the users table.