'Study..'에 해당되는 글 80건

  1. 2008.10.28 Javascript 계산기
  2. 2008.10.25 get / post 방식


[code]<html>
<head>
<script type="text/javascript">
function plus() {
temp.value = num.value ; type.value = 1; num.value = "" }
function minus() {
temp.value = num.value ; type.value = 2; num.value = "" }
function mul() {
temp.value = num.value ; type.value = 3; num.value = "" }
function div() {
temp.value = num.value ; type.value = 4; num.value = "" }

function get_result() {
if(type.value==1) {num.value = parseInt(temp.value) + parseInt(num.value);}
if(type.value==2) {num.value = parseInt(temp.value) - parseInt(num.value);}
if(type.value==3) {num.value = parseInt(temp.value) * parseInt(num.value);}
if(type.value==4) {num.value = parseInt(temp.value) / parseInt(num.value);}
temp.value = "";
}

</script>
</head>

<body>
<input type="text" size="10" id="num"><br>
<input type="button" value="+" onclick="plus()">
<input type="button" value="-" onclick="minus()">
<input type="button" value="*" onclick="mul()">
<input type="button" value="/" onclick="div()"><br>
<input type="button" value="      =      " onclick="get_result()">
<input type="hidden" size="10" id="temp">
<input type="hidden" size="10" id="type">
</body>
</html>[/code]


 html 기반의 Javascript 를 이용한 계산기.

w3c school 참조 하였으며,
결과값을 이용한 연속 연산도 가능하도록 되어 있고,
JS 특성상 zero divisor 등에 대해서도 무한대 결과 출력이라던가,
정상적인 값이 아니면 non 이 뜨는 등 에러 처리도 된다.

(첫번째꺼 빼고는 ) 내가 일일이 다 구현한 것도 아니지만
JS 라서 다 된다...  -_-;;;



신기하다.
인터넷 응용프로그래밍 중간고사 치고 나니깐...
JS 로 뭔가 만드는게 좀 주저함이 많이 없어졌다.
이번에 중간고사때 실제 손 코딩은 처음 해봤는데도 이런다. ;;;

'Study.. > Programming' 카테고리의 다른 글

race condition ( thread, mutex, semaphore)  (0) 2009.05.29
no newline at end of file  (0) 2009.05.29
printf 의 16진수 / 8진수 출력..  (0) 2008.09.18
Intelligent completion at Vim 7.0  (0) 2008.06.03
_beginthreadex  (2) 2007.11.16
Posted by Yoons...
,

get / post 방식

Study../etcs.. 2008. 10. 25. 12:07

Internet method 를 전송하는 두가지 방식 get / post

get 방식은 주소창에 데이터가 노출되고, 따라서 보안에 약하지만, 처리가 쉽고 속도가 빠르다.
post 방식은 반대임.

주의할 점..
인코딩 등은 다른 사이트 참조.

'Study.. > etcs..' 카테고리의 다른 글

mysql DB access..  (0) 2008.11.12
mysql 접속...  (0) 2008.11.12
현재 옮겨져 있는 신의키스 홈페이지.  (0) 2008.10.25
ISM band  (0) 2008.06.04
컴공 인이 "꼭" 봐야 할 책 list.. (MS 사 직원분 추천..)  (2) 2008.04.03
Posted by Yoons...
,