-1

I need to get the variable speedMbps from the code below so i can do a if-else statement using php.

i have this form that allow users to select videos from dropdownlist, depending on users connection the selected video will be display.

function showResults() {
        var duration = (endTime - startTime) / 1000;
        var bitsLoaded = downloadSize * 8;
        var speedBps = (bitsLoaded / duration).toFixed(2);
        var speedKbps = (speedBps / 1024).toFixed(2);
        var speedMbps = (speedKbps / 1024).toFixed(2);
        oProgress.innerHTML = "Your connection speed is: <br />" + 
           speedBps + " bps<br />"   + 
           speedKbps + " kbps<br />" + 
           speedMbps + " Mbps<br />";
Mick Jack
  • 550
  • 1
  • 5
  • 21

1 Answers1

0

you should use Ajax post getting:

HTML & Jquery

<input type="text" id="results" />
<script> 
    $.ajax({
        url: "test_select.php",
        data: {speedMbps: speedMbps },
        cache: false
    }).done(function( html ) {
        $( "#results" ).val( html );
    });
</script>

PHP file "test_select.php"

<?php
    echo $_POST['speedMbps'];
?>

Remember about:

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
Mergars
  • 18
  • 8