Friday, August 9, 2013

Create Mathematical Validation in Phone

create input, box and operation div in the html file.
write below code in the js file.
var answer;

var method = ['+', '-', '*'];
var operation;
//var operation='1+2+3';

// load new operation on page laod
new_operation();

Wednesday, July 10, 2013

Get Element Attribute Value using jQuery

Create textarea element to enter html content dynamic

// button click
$('#click_elemtn').click(function(){
    var str= $('#html_content').text();
    html = $.parseHTML( str ); // parse text to html
    $.each( html, function( i, el ) {
        var attr = $(el).attr('src'); // attribute name that you want fro the textarea content
        if (typeof attr !== 'undefined' && attr !== false) {
            alert(attr); // attribute value
        }
    });
});

you can get attribute value in alert dialog.

refer below URL for live example

http://jsfiddle.net/RNmJ2/

Thursday, May 16, 2013

Add class to link which contains ".pdf" file

Add pdf icon to whole site pdf URLwhich are in the content_area.

In jQuery a[href*=".pdf"]' syntax contains all the elements which link ref contain .pdf
Add specific class to PDF links.

$('.content_area a[href*=".pdf"]').addClass('pdf_doc');

Apply below css to given class to add PDF icon to link to highlight.

.pdf_doc {
background: url("pdf.png") no-repeat scroll left 0;
padding-left: 20px;
background-size: 18px;
}

Friday, April 19, 2013

Get File Last Modified Date-Time

<?php

$filename = 'somefile.txt';
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
}

?>

this file modify date is used for the mobile application to get updates are available or not on the server file.

Get County from User Lat Long

In Mobile application how the server knows about the posted device country and response then as per the location.

Get the current location of the device and use google map api to get user location. Get location from the ipaddress is a worth thing now. because all the internet user use proxy network.

PHP:

<?php

$cur_lat =$_REQUEST['lat'];
$cur_lon = $_REQUEST['lon'];