Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

bytes to MB etc

Discussion in 'General Discussion' started by kernow, Feb 1, 2006.

  1. kernow

    kernow Well-Known Member

    Joined:
    Jul 23, 2004
    Messages:
    920
    Likes Received:
    13
    Trophy Points:
    168
    cPanel Access Level:
    Root Administrator
    Example: received 1926223517 bytes
    Eh?? how much is that??
    If, like me you find converting bytes to MB or GBs a real pain in the bum :mad:
    Here's a neat script i found to make it easy. Paste this into a html page.
    Code:
    <form name="bandwidth">
    
      <p><input type="text" name="original" size="20" value=1024> <select size="1" name="units">
        <option value="Bytes">Bytes</option>
        <option value="Kb">Kb</option>
        <option value="Mb">Mb</option>
        <option value="Gb">Gb</option>
      </select> <input type="button" value="Calculate" name="B1" onClick="calculate()"></p>
    </form>
    
    <p>
    
    <script>
    
    /*
    Bandwidth calculator (credit must stay enclosed)
    By javascriptkit.com
    For this and over 400+ JavaScripts,
    Visit http://www.javascriptkit.com
    */
    
    var bytevalue=0
    function calculate(){
    var invalue=document.bandwidth.original.value
    var selectunit=document.bandwidth.units.options[document.bandwidth.units.selectedIndex].value
    if (selectunit=="Bytes")
    bytevalue=invalue
    else if (selectunit=="Kb")
    bytevalue=invalue*1024
    else if (selectunit=="Mb")
    bytevalue=invalue*1024*1024
    else if (selectunit=="Gb")
    bytevalue=invalue*1024*1024*1024
    
    alert (invalue+" "+selectunit+" is equal to:\n\n- "+bytevalue+" Bytes\n- "+Math.round(bytevalue/1024)+" Kb\n- "+Math.round(bytevalue/1024/1024)+" Mb\n- "+Math.round(bytevalue/1024/1024/1024)+" Gb\n")
    }
    
    </script>
    
    <p align="center"><font face="arial" size="-2">This free script provided by</font><br>
    <font face="arial, helvetica" size="-2"><a href="http://javascriptkit.com">JavaScript
    Kit</a></font></p>
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  2. lloyd_tennison

    lloyd_tennison Well-Known Member

    Joined:
    Mar 12, 2004
    Messages:
    698
    Likes Received:
    1
    Trophy Points:
    168
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice