How to add an alert statement to JQuery?

Question!

I just want to show an alert when the computation is done. It is inside my JQuery script.

Here's my code:

<script language="javascript">
$('document').ready(function() {
    $('#payable').change(function() {
        var str = $('#payable').val();
        var value = $('#value').val();
        if (str == "1 Week") {
           var result = value / 6;
           $("#deduc").val(result);
        } else if(str == '1 Month'){
           var result = value / 24;
           $("#deduc").val(result);
        } else if(str == '2 Months'){
           var result = value / 48;
           $("#deduc").val(result);
        }
    })
})
</script>


Answers

If I'm not mistaken to add an alert after the function is done you can just add one line before the end of your script

$('#payable').change(function() {
    var str = $('#payable').val();
    var value = $('#value').val();
    if (str == "1 Week") {
       var result = value / 6;
       $("#deduc").val(result);
    } else if(str == '1 Month'){
       var result = value / 24;
       $("#deduc").val(result);
    } else if(str == '2 Months'){
       var result = value / 48;
       $("#deduc").val(result);
    }
    alert("Completed!");
})


Depends on how accurate you want the speedtest to be, the larger the file the more accurate it is. But this can be a big annoyance/data hog for the user.

The big number appears because it's in bytes, to get Mb/s you need to do Your result / 1024^2.



Disable attribute only associates button and input filelds, the thing you want to do here is , event.preventDefault . It will work like disable, but it will depend upon your coding, if you want to show it disabled, you have to add add via jquery



This video can help you solving your question :)
By: admin