The output of above string is c ( Hex value of 12 )
The input variable must be an integer. So we will use paraseInt() function to convert any input to pure integer value.
We will also use isNan function to check the user input.
<html>
<head>
<title>Demo of decimal to hexadecimal conversion</title>
<script language='JavaScript' type='text/JavaScript'>
<!--
function hex_convt(){
var n1=document.getElementById('t1').value;
if(isNaN(n1)){
document.getElementById("d1").innerHTML=document.getElementById('t1').value + " is not a number ";
}else{
n1=parseInt(n1);
document.getElementById("d1").innerHTML=n1.toString(16);
// Change the toString(16) to toString(8) or toString(2) get Octal and binary conversion
}