»
EnglishFrenchVietnamese

Print - Javascript Size Calc - JavaScriptBank.com

Full version: jsB@nk » Calculation » Calculator » Javascript Size Calc
URL: https://www.javascriptbank.com/javascript-size-calc.html

Javascript Size Calc © JavaScriptBank.comThis is a small JavaScript which calculates the size of a message. Type or paste in anything and try it out.

Full version: jsB@nk » Calculation » Calculator » Javascript Size Calc
URL: https://www.javascriptbank.com/javascript-size-calc.html



JavaScript
<SCRIPT language=javascript>function calc_length(){var doc1 = document.form1.S1.value                   //The Value of the Msg to be calc.document.form1.box.value = doc1.length + " Bytes"    //Write the length, in bytes to the boxvar rohn1 = doc1.length / 1024                       //Divide the bytes by 1024, since 1kb = 1024, not 1000var rohn2 = rohn1 * 1000     //Multiply it by 1000 to get the part to roundvar rohn3 = parseInt(rohn2)      //round the numbervar kb   = rohn3 /1000      //Return the value into kb, rounding the original numberdocument.form1.box2.value = kb + " KB"     //write the amount of kb in the second box}</SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<FORM name=form1><TEXTAREA name=S1 rows=10 cols="25">This is a simple script to calculate the length of a message. This is useful if you want a visitor to submit comments at your site under a certain limit.</TEXTAREA><BR><INPUT onclick=calc_length() type=button value="Calculate Length" name=b1><BR>  <INPUT style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" disabled name=box size="20"><BR>  <INPUT style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" disabled name=box2 size="20"><br>by <A href="mailto:glock64@hotmail.com">glock64</A></FORM><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->