Thursday, 11 June 2015

How to refresh the button or div or ul


                                         Phonegap Application Learning


1. How to Refresh the listview in JQuery Mobile Application.

          $('#ojt_list').listview().listview('refresh');
      
           ojt_list ==> call div of  ul --> Id
   
           ex. <ul id="ojt_list" data-role="listview" data-inset="true">

2.  How to Refresh the Div in JQuery Mobile Application.

           $( "#ojt_quiz_views" ).find( "ul" ).listview().listview( "refresh" );

           ojt_quiz_views ==> call Div Id
       
           ex. <div data-role="content" id="ojt_quiz_views" ></div>
          
3.  How to Refresh the Div in JQuery Mobile Application.

           $('input[type=button]').button().trigger('create');

 4.  How to Refresh the <select name="" id="evolitionmodule"></select>?

            $('#evolitionmodule').empty().append(content).selectmenu('refresh');


5. how to get the radio button value if checked radio button.

           var id_gen ="your radio button name";

          var option_value =document.querySelector('input[name="'+id_gen+'"]:checked').value;
                   
                                                            (OR)

  var radioValue = $('input[name="'+id_gen+'"]:checked').val();








Wednesday, 14 January 2015

workable coding for Android cordova/phonegap application. 3.1 version


                                                           URL For Working Code Location



uploading image from mobile to server. ==>working=>100%



android ==> div part.

<div class="app" style="display:block">
    <h1>File Upload - Shashi Badhuk</h1>
    <div id="main">
        <h3>Uploading Image from Phonegap Mobile App to PHP backend</h3>
        <div id="server-div">
            Server URL : <input type="text" name="server" id="server" value="http://chandandroid.uphero.com/filecheck/uploading.php"/>
        </div>
        <div id="image-upload" onClick="uploadImage()">
            <img id="pimage" src="img/profile.png" width="100px" height="100px" />
        </div>
        <div id="picture_msg">
            Tap on Image to change and upload
        </div>
    </div>
</div>


javascript.


 function uploadImage() {
    document.getElementById('picture_msg').innerHTML = "";
    // Get URI of picture to upload
    navigator.camera.getPicture(
        function(uri) {
            try {
                // Pick image from div
                var img = document.getElementById('pimage');
                img.style.visibility = "visible";
                img.style.display = "block";
                var imageURI = uri;
                if (!imageURI || (img.style.display == "none")) {
                    document.getElementById('picture_msg').innerHTML = "Tap on picture to select image from gallery.";
                    return;
                }
                // Verify server has been entered
                server = document.getElementById('server').value;
                console.log("Server "+server);
                if (server) {
                    // Specify transfer options
                    var options = new FileUploadOptions();
                    options.fileKey="file";
                    options.fileName=imageURI.substr(imageURI.lastIndexOf('/')+1);
                    options.mimeType="image/jpeg";
                    options.chunkedMode = false;
                             
                    // Transfer picture to server
                    var ft = new FileTransfer();
                    ft.upload(imageURI, server, function(r) {
                        document.getElementById('picture_msg').innerHTML = "Upload successful: "+r.bytesSent+" bytes uploaded.";
                        img.src = uri;
                        img.width = 100;
                        img.height = 100;
                    },
                    function(error) {
                        document.getElementById('picture_msg').innerHTML = "Upload failed: Code = "+error.code;
                    }, options);
                }
                else {
                    document.getElementById('picture_msg').innerHTML = "Server Not Found";
                }
            }
            catch(exce) {
                alert(exce);
            }
        },
        function(e) {
            console.log("Error getting picture: " + e);
            document.getElementById('picture_msg').innerHTML = "No Image Found";
        },
        {
            quality: 50,
            destinationType: navigator.camera.DestinationType.FILE_URI,
            sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY
        }
    );
}





Reference code from...

Click