Tuesday, September 12, 2017

HTML Scripts to do some basic functions.

To Play a sound-file inside HTML
<script>
function playOkay(){
        $("body").append("<embed src='sliit_std_mng_sounds/all_okay.mp3' autostart='true' loop='false' width='2' height='0'></embed>");
}
</script>


Reload web-page after a certain time period
 <script>
 function autoRefresh1()
{
       window.location.reload();
}
 function timeRefresh()
 {
 setInterval('autoRefresh1()', 5000); // this will reload page after every 5 secounds
 }
    </script>

Redirect to another page after a certain time
<script type="text/JavaScript">
function timedRefresh(timeoutPeriod){
    setTimeout("window.location.href = '#';",timeoutPeriod);
}
</script>

A script to change another input box as per for the input 
(eg. when entered discount percentage, showing total fee)

        function getdiscount() {
            var txtFirstNumberValue = document.getElementById('txt1').value;
            var txtSecondNumberValue = document.getElementById('txt2').value;
            var result = parseFloat(txtFirstNumberValue) * parseFloat(txtSecondNumberValue/100);
           
            if (!isNaN(result))
            {
                document.getElementById('txt3').value = result;
                getfullc_fee();
              
            }
        }
</script>
<script>
function getfullc_fee()
{
    var txtFirstNumberValue = document.getElementById('txt1').value;
    var txtdis = document.getElementById('txt3').value;
    var fullfee = txtFirstNumberValue - txtdis;
                         

    //display the result
    document.getElementById('totalPrice').value = fullfee;

}
</script>




No comments:

Post a Comment

Implemting Google Drive File Uploader using OAuth

Implementing Google Drive Text File Uploader using OAuth 2.0 Creating Project and Registering your API with Google In this part we wil...