Monday 28 December 2015

get current google loaction

    <div id="google_canvas"></div>
   
        <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true"></script>
   
        <script>
        (function() {
       
            if(!!navigator.geolocation) {
           
                var map;
           
                var mapOptions = {
                    zoom: 15,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };
               
                map = new google.maps.Map(document.getElementById('google_canvas'), mapOptions);
           
                navigator.geolocation.getCurrentPosition(function(position) {
               
                    var geolocate = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
                   
                    var infowindow = new google.maps.InfoWindow({
                        map: map,
                        position: geolocate,
                        content:
                            '<h1>Location pinned from HTML5 Geolocation!</h1>' +
                            '<h2>Latitude: ' + position.coords.latitude + '</h2>' +
                            '<h2>Longitude: ' + position.coords.longitude + '</h2>'
                    });
                   
                    map.setCenter(geolocate);
                   
                });
               
            } else {
                document.getElementById('google_canvas').innerHTML = 'No Geolocation Support.';
            }
           
        })();
        </script>

Wednesday 19 August 2015

dynamic element add each function jquery


$("#regproduct").click(function() {
            $("#specification .parameter").each(function(i, obj)
            {
                var data = $(this).select2("val");
                if (data == '')
                {
                    $("#specificationshow").show();
                    return false;
                }
            })
        })

Friday 26 June 2015

find charecter in array

 $array=your array

foreach($array as $key=>$val)
            {
                $pos = stripos($val['name'],$searchkey);
                if($pos!== false)
                {
                 
                    $returnarray[]=$usertypearray[$key];
                  
                }
            }
        }

Thursday 18 June 2015

numeric value insert only

 /*
    * only numeric value insert in specification
    */
  //called when key is pressed in textbox
   $("body").on('keypress','.numeric',function (e) {
     //if the letter is not digit then display error and don't type anything
     if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
       
               return false;
    }
  
  });
 

});

$(document).ready(function(){
    $(document).on("cut copy paste",".numeric",function(e) {
        e.preventDefault();
    });
 });

Thursday 11 June 2015

onbeforeunload unbind/bind on page before leave page

For unbind
  window.onbeforeunload = null;

For Bind
    
  function closeIt()
  {
    return "Are you sure you want to cancel this posting?";
  }
  window.onbeforeunload = closeIt;

Monday 1 June 2015

set maxdate depend on mindate in datepicker

     var startDate = $(this).datepicker('getDate');
                   startDate.setDate(startDate.getDate() +30);
                    $("#offer_expiredate").datepicker("option", "minDate", selected);