I have a form where a user enters a decimal number and then from the dropdown menu he chooses if he wants to convert it either to binary, octal or hexadecimal by clicking on a c
If you want to convert a number to hexadecimal representation, you can use toString method. First argument of toString can be a radix for numbers. Example:
var n = 12;
n.toString(); // "c"
If you want to convert back, you can use parseInt...
var hexnum = "c";
parseInt(hexnum,16); // 12
These functions works for any radix.
Here is the full source code:
Convertor
Enter decimal number to convert, select Base and click CONVERT.