JavaScript Scripts





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Free Java Script Codes
Javascript List All
Slide Show Slide Show
Ad Display Ad Display
Image Effect Image Effect
Animated Image Effects Animated Image Effects
Form Validation Form Validation
Color Picker Tool Color Picker Tool
Formatting Forms Formatting Forms
Select All Select All
Dynamic Form Select Dynamic Form select
Dynamic Color Dynamic Color
Calendar Script Calendar
Textbox Counter Textbox Counter
Alphanumeric Alphanumeric
Date Time Script Date & Time
Stop Watch Script Stop Watch script
Delete Repeated Values Delete Repeated Values
Pagination Pagination
Random Generator Random Generator
Animated Text Animated Text
Cursor Position Cursor Position
User Info Window / User Info
Security Security / Authenticate
Bookmark Bookmark
Mouse Effects Mouse Effects
Title Bar Title Bar
Status Bar Status Bar
Country List Country List
Free Games Free Games
Calculators Calculators
 




Javascript-Decimal to Binary conversion


About
Javascript decimal number to binary value conversion is used to calculate binary value for a given decimal number.


Features
a) You can convert decimal number to binary value using this javascript.
b) Just copy the code and use it.

Preview
Enter decimal number to convert it to binary value

Decimal Number:

Binary Number:   


Code
  Javascript Code
<!-- Script by hscripts.com -->
<script type="text/javascript"> function isNum(args) { args = args.toString(); if (args.length == 0) return false; for (var i = 0;i<args.length;i++) { if (args.substring(i,i+1) < "0" || args.substring(i, i+1) > "9") { return false; } } return true; } function deciToBin(arg) { res1 = 999; args = arg; while(args>1) { arg1 = parseInt(args/2); arg2 = args%2; args = arg1; if(res1 == 999) { res1 = arg2.toString(); } else { res1 = arg2.toString()+res1.toString(); } } if(args == 1 && res1 != 999) { res1 = args.toString()+res1.toString(); } else if(args == 0 && res1 == 999) { res1 = 0; } else if(res1 == 999) { res1 = 1; } var ll = res1.length; while(ll%4 != 0) { res1 = "0"+res1; ll = res1.length; } return res1; } function change(name) { var sd = name.value; if(isNum(sd)) { var result = deciToBin(sd); document.first.deciBin.value = result; } else { document.first.deci.value = sd.substring(0,sd.length-1) ; } } </script>
<!-- Script by hscripts.com -->


Get free version without ©copyright link for just 5 price

For customization of this script or any script development, contact us at support@hscripts.com


Usage
Here we have explained with a form
a) Copy the HTML code given below to create form
<form name=first>
Decimal Number: <input name=deci type="text" onkeyup="change(this)" size=20>
Binary Number: <input name=deciBin type="text" size=20 readonly class=resform>
</form>

b) Copy the above Javascript code into your page and use it.
c) If decimal number is entered in the textbox. The javascript function "change()" converts the given value into binary number.



License
- The javascript (misspelled as java script) is given under GPL License
- i.e. Free use for those who use the codes as it is.
- Free, if your modification does not remove our copyright information and links.
- Click Here for detailed license information.
- You can purchase the script if your requirements does not meet our GPL License terms.
Other Links

web hosting