console
function covert(){
var a=document.getElementById("one").value
var b = a.charCodeAt();
document.getElementById("two").value=b
}
function clear_value(){
var x = document.getElementsByTagName("input");
var i;
for (i = 0; i < x.length; i++) {
x[i].value = "";
}
}
<html>
<head><title>js</title></head>
<body>
<div style="margin-left:300px">
<h2>字符转换成ASCII码</h2>
<input type="text" id="one" placeholder='请输入任意字符'/>
<button onclick="covert()">转换</button>
<input type='text' id='two' placeholder='转换结果'/>
<button onclick="clear_value()" >清空</button>
</div>
</body>
</html>