728x90
반응형

<!DOCTYPE html>

<html>

<head>

<meta charset="EUC-KR">

<title>Insert title here</title>

<script>

function showResult() {

var a = document.getElementById("num1");

var b = document.getElementById("num2");

var c = parseInt(a.value)+parseInt(b.value);    //    parseInt 를 이용하여 문자열을 숫자로 변환

var d = document.getElementById("num3");

d.value = c;

}

</script>

</head>

<body> 

<input type="text" id="num1"/>+

<input type="text" id="num2"/>=

<input type="text" id="num3"/>

<br/>


<input type="button" value="두수합" onclick="showResult();"/>



</body>

</html>




[결과] 




728x90
반응형

+ Recent posts