// [1단계] 아래의 소스코드를 <HEAD>와 </HEAD> 사이에 붙여 넣으세요
<script language="JavaScript">
<!--
function a_plus_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=a+b
form.ans.value = c
}
function a_minus_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=a-b
form.ans.value=c
}
function a_times_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=a*b
form.ans.value=c
}
function a_div_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=a/b
form.ans.value = c
}
function a_pow_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=Math.pow(a, b)
form.ans.value = c
}
// -->
</script>
// 여기까지 입니다
// [2단계] 아래의 코드를 원하는 위치에 복사 해 넣으세요
<form name="formx"><input type=text size=4 value=12 name="a">
<input type="button" value=" + " onClick="a_plus_b(this.form)">
<input type="button" value=" - " onClick="a_minus_b(this.form)">
<input type="button" value=" x " onClick="a_times_b(this.form)">
<input type="button" value=" / " onClick="a_div_b(this.form)">
<input type="button" value=" ^ " onClick="a_pow_b(this.form)">
<input type="number" size=4 value=3 name="b"> = <input type "number" value=0 name="ans" size=9>
</form>
<!---->
<script language="JavaScript">
<!--
function a_plus_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=a+b
form.ans.value = c
}
function a_minus_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=a-b
form.ans.value=c
}
function a_times_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=a*b
form.ans.value=c
}
function a_div_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=a/b
form.ans.value = c
}
function a_pow_b(form) {
a=eval(form.a.value)
b=eval(form.b.value)
c=Math.pow(a, b)
form.ans.value = c
}
// -->
</script>
// 여기까지 입니다
// [2단계] 아래의 코드를 원하는 위치에 복사 해 넣으세요
<form name="formx"><input type=text size=4 value=12 name="a">
<input type="button" value=" + " onClick="a_plus_b(this.form)">
<input type="button" value=" - " onClick="a_minus_b(this.form)">
<input type="button" value=" x " onClick="a_times_b(this.form)">
<input type="button" value=" / " onClick="a_div_b(this.form)">
<input type="button" value=" ^ " onClick="a_pow_b(this.form)">
<input type="number" size=4 value=3 name="b"> = <input type "number" value=0 name="ans" size=9>
</form>
<!---->
'java script' 카테고리의 다른 글
| 간단한 곱하기 계산 스크립트 (0) | 2011.01.07 |
|---|---|
| 깔끔한 다기능 계산기 (0) | 2011.01.07 |
| 자바스크립트 풀다운 메뉴 만들기 (0) | 2011.01.07 |
| [버튼시리즈] 누를때마다 다른 메세지를 보여줍니다 (0) | 2011.01.07 |
| [버튼시리즈] 폼버튼으로 멋진 텍스트 배너를 만들어 보자 (0) | 2011.01.07 |