Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- 'use strict';
- function $(id) {
- return document.getElementById(id);
- }
- //Decimal point works only for base 10(decimal) number!
- function baseConverter(str, fromBase, toBase) {
- str = /\./.test(str) ? +str : parseInt(str, fromBase);
- return str.toString(toBase);
- }
- var form = $('form');
- form.onchange = function() {
- form.out_data.value = baseConverter(form.input_data.value,
- form.fromBase.value,
- form.toBase.value);
- };
- }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement