<HTML>
<HEAD>
<TITLE>금액 출력</TITLE>
<SCRIPT Language='JavaScript'>
//금액에 , 찍기
function numchk(num){
num=new String(num);
num=num.replace(/,/gi,"");
return numchk1(num);
}
function numchk1(num){
var sign="";
if(isNaN(num)) {
alert("숫자만 입력할 수 있습니다.");
return 0;
}
if(num==0) {
return num;
}
if(num<0){
num=num*(-1);
sign="-";
}
else{
num=num*1;
}
num = new String(num)
var temp="";
var pos=3;
num_len=num.length;
while (num_len>0){
num_len=num_len-pos;
if(num_len<0) {
pos=num_len+pos;
num_len=0;
}
temp=","+num.substr(num_len,pos)+temp;
}
return sign+temp.substr(1);
}
// 금액 숫자를 한글로
function num_han(num)
{
if ( num == "1" ) return "일";
else if ( num == "2" ) return "이";
else if ( num == "3" ) return "삼";
else if ( num == "4" ) return "사";
else if ( num == "5" ) return "오";
else if ( num == "6" ) return "육";
else if ( num == "7" ) return "칠";
else if ( num == "8" ) return "팔";
else if ( num == "9" ) return "구";
else if ( num == "십" ) return "십";
else if ( num == "백" ) return "백";
else if ( num == "천" ) return "천";
else if ( num == "만" ) return "만 ";
else if ( num == "억" ) return "억 ";
else if ( num == "조" ) return "조 ";
else if ( num == "0" ) return "";
}
function NUM_HAN(num,mode,return_input)
{
if ( num == "" || num == "0" ) {
if ( mode == "3" ) {
return_input.value = "";
}
return;
}
num=new String(num);
num=num.replace(/,/gi,"");
var len = num.length;
var temp1 = "";
var temp2 = "";
if ( len/4 > 3 && len/4 <= 4 ) {
if ( len%4 == 0 ) {
temp1 = ciphers_han(num.substring(0,4)) + "조" + ciphers_han(num.substring(4,8)) + "억" + ciphers_han(num.substring(8,12)) + "만" + ciphers_han(num.substring(12,16));
}
else {
temp1 = ciphers_han(num.substring(0,len%4)) + "조" + ciphers_han(num.substring(len%4,len%4+4)) + "억" + ciphers_han(num.substring(len%4+4,len%4+8)) + "만" + ciphers_han(num.substring(len%4+8,len%4+12));
}
}
else if ( len/4 > 2 && len/4 <= 3 ) {
if ( len%4 == 0 ) {
temp1 = ciphers_han(num.substring(0,4)) + "억" + ciphers_han(num.substring(4,8)) + "만" + ciphers_han(num.substring(8,12));
}
else {
temp1 = ciphers_han(num.substring(0,len%4)) + "억" + ciphers_han(num.substring(len%4,len%4+4)) + "만" + ciphers_han(num.substring(len%4+4,len%4+8));
}
}
else if ( len/4 > 1 && len/4 <= 2 ) {
if ( len%4 == 0 ) {
temp1 = ciphers_han(num.substring(0,4)) + "만" + ciphers_han(num.substring(4,len));
}
else {
temp1 = ciphers_han(num.substring(0,len%4)) + "만" + ciphers_han(num.substring(len%4,len));
}
}
else if ( len/4 <= 1 ) {
temp1 = ciphers_han(num.substring(0,len));
}
for (var i=0; i<temp1.length; i++) {
temp2 = temp2 + num_han(temp1.substring(i, i+1));
}
temp3=new String(temp2);
temp3=temp3.replace(/억 만/gi,"억 ");
temp3=temp3.replace(/조 억/gi,"조 ");
if ( mode == 1 ) {
alert(temp3 + " 원");
} else if ( mode == 2 ) {
return temp3;
} else if ( mode == 3 ) {
return_input.value = "( " + temp3 + " 원 )";
}
}
function ciphers_han(num)
{
var len = num.length;
var temp = "";
if ( len == 1 ) {
temp = num;
}
else if ( len == 2 ) {
temp = num.substring(0,1) + "십" + num.substring(1,2);
}
else if ( len == 3 ) {
temp = num.substring(0,1) + "백" + num.substring(1,2) + "십" + num.substring(2,3);
}
else if ( len == 4 ) {
temp = num.substring(0,1) + "천" + num.substring(1,2) + "백" + num.substring(2,3) + "십" + num.substring(3,4);
}
num=new String(temp);
num=num.replace(/0십/gi,"");
num=num.replace(/0백/gi,"");
num=num.replace(/0천/gi,"");
return num;
}
function moncom(mon) {
var factor = mon.length % 3;
var su = (mon.length - factor) / 3;
var com = mon.substring(0,factor);
for(var i=0; i < su ; i++) {
if((factor == 0) && (i == 0)) {
com += mon.substring(factor+(3*i), factor+3+(3*i));
}
else {
com += "," ;
com += mon.substring(factor+(3*i), factor+3+(3*i));
}
}
document.write(com);
}
</SCRIPT>
</HEAD>
<body>
금액<form name=form action=# method=get>
<input type="text" name="A_EMONEY" size=18 maxLength=15 style="text-align:right" onkeypress="NUM_HAN(this.value,3,document.form.EMONEY_HAN)" onkeyup="this.value=numchk(this.value);NUM_HAN(this.value,3,document.form.EMONEY_HAN)"> 원
<input type="text" name="EMONEY_HAN" readonly style="border:0;" size="50">
</form>
</body>
</html><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]</div>
<HEAD>
<TITLE>금액 출력</TITLE>
<SCRIPT Language='JavaScript'>
//금액에 , 찍기
function numchk(num){
num=new String(num);
num=num.replace(/,/gi,"");
return numchk1(num);
}
function numchk1(num){
var sign="";
if(isNaN(num)) {
alert("숫자만 입력할 수 있습니다.");
return 0;
}
if(num==0) {
return num;
}
if(num<0){
num=num*(-1);
sign="-";
}
else{
num=num*1;
}
num = new String(num)
var temp="";
var pos=3;
num_len=num.length;
while (num_len>0){
num_len=num_len-pos;
if(num_len<0) {
pos=num_len+pos;
num_len=0;
}
temp=","+num.substr(num_len,pos)+temp;
}
return sign+temp.substr(1);
}
// 금액 숫자를 한글로
function num_han(num)
{
if ( num == "1" ) return "일";
else if ( num == "2" ) return "이";
else if ( num == "3" ) return "삼";
else if ( num == "4" ) return "사";
else if ( num == "5" ) return "오";
else if ( num == "6" ) return "육";
else if ( num == "7" ) return "칠";
else if ( num == "8" ) return "팔";
else if ( num == "9" ) return "구";
else if ( num == "십" ) return "십";
else if ( num == "백" ) return "백";
else if ( num == "천" ) return "천";
else if ( num == "만" ) return "만 ";
else if ( num == "억" ) return "억 ";
else if ( num == "조" ) return "조 ";
else if ( num == "0" ) return "";
}
function NUM_HAN(num,mode,return_input)
{
if ( num == "" || num == "0" ) {
if ( mode == "3" ) {
return_input.value = "";
}
return;
}
num=new String(num);
num=num.replace(/,/gi,"");
var len = num.length;
var temp1 = "";
var temp2 = "";
if ( len/4 > 3 && len/4 <= 4 ) {
if ( len%4 == 0 ) {
temp1 = ciphers_han(num.substring(0,4)) + "조" + ciphers_han(num.substring(4,8)) + "억" + ciphers_han(num.substring(8,12)) + "만" + ciphers_han(num.substring(12,16));
}
else {
temp1 = ciphers_han(num.substring(0,len%4)) + "조" + ciphers_han(num.substring(len%4,len%4+4)) + "억" + ciphers_han(num.substring(len%4+4,len%4+8)) + "만" + ciphers_han(num.substring(len%4+8,len%4+12));
}
}
else if ( len/4 > 2 && len/4 <= 3 ) {
if ( len%4 == 0 ) {
temp1 = ciphers_han(num.substring(0,4)) + "억" + ciphers_han(num.substring(4,8)) + "만" + ciphers_han(num.substring(8,12));
}
else {
temp1 = ciphers_han(num.substring(0,len%4)) + "억" + ciphers_han(num.substring(len%4,len%4+4)) + "만" + ciphers_han(num.substring(len%4+4,len%4+8));
}
}
else if ( len/4 > 1 && len/4 <= 2 ) {
if ( len%4 == 0 ) {
temp1 = ciphers_han(num.substring(0,4)) + "만" + ciphers_han(num.substring(4,len));
}
else {
temp1 = ciphers_han(num.substring(0,len%4)) + "만" + ciphers_han(num.substring(len%4,len));
}
}
else if ( len/4 <= 1 ) {
temp1 = ciphers_han(num.substring(0,len));
}
for (var i=0; i<temp1.length; i++) {
temp2 = temp2 + num_han(temp1.substring(i, i+1));
}
temp3=new String(temp2);
temp3=temp3.replace(/억 만/gi,"억 ");
temp3=temp3.replace(/조 억/gi,"조 ");
if ( mode == 1 ) {
alert(temp3 + " 원");
} else if ( mode == 2 ) {
return temp3;
} else if ( mode == 3 ) {
return_input.value = "( " + temp3 + " 원 )";
}
}
function ciphers_han(num)
{
var len = num.length;
var temp = "";
if ( len == 1 ) {
temp = num;
}
else if ( len == 2 ) {
temp = num.substring(0,1) + "십" + num.substring(1,2);
}
else if ( len == 3 ) {
temp = num.substring(0,1) + "백" + num.substring(1,2) + "십" + num.substring(2,3);
}
else if ( len == 4 ) {
temp = num.substring(0,1) + "천" + num.substring(1,2) + "백" + num.substring(2,3) + "십" + num.substring(3,4);
}
num=new String(temp);
num=num.replace(/0십/gi,"");
num=num.replace(/0백/gi,"");
num=num.replace(/0천/gi,"");
return num;
}
function moncom(mon) {
var factor = mon.length % 3;
var su = (mon.length - factor) / 3;
var com = mon.substring(0,factor);
for(var i=0; i < su ; i++) {
if((factor == 0) && (i == 0)) {
com += mon.substring(factor+(3*i), factor+3+(3*i));
}
else {
com += "," ;
com += mon.substring(factor+(3*i), factor+3+(3*i));
}
}
document.write(com);
}
</SCRIPT>
</HEAD>
<body>
금액<form name=form action=# method=get>
<input type="text" name="A_EMONEY" size=18 maxLength=15 style="text-align:right" onkeypress="NUM_HAN(this.value,3,document.form.EMONEY_HAN)" onkeyup="this.value=numchk(this.value);NUM_HAN(this.value,3,document.form.EMONEY_HAN)"> 원
<input type="text" name="EMONEY_HAN" readonly style="border:0;" size="50">
</form>
</body>
</html><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 16:57:14 JavaScript에서 이동 됨]</div>
게시글 목록
| 번호 | 제목 |
|---|---|
| 10705 |
Linux
LINUX 해킹당했을 때 대처요령
2
|
| 10698 | |
| 10697 |
Flash
웹문서에 페이지 로딩중 효과 | SCRIPT
|
| 10693 |
JavaScript
플래쉬에서팝업창띄우기
3
|
| 10687 |
Flash
플래쉬 팁 여러가지
5
|
| 10683 | |
| 10681 | |
| 10680 | |
| 10677 | |
| 10671 | |
| 10670 |
JavaScript
smtp로 메일보내기(102번 게시물과는 다른 방법)
|
| 10666 | |
| 10664 |
JavaScript
아이프레임 자동으로 늘어나는 자바 스크립트.
1
|
| 10658 | |
| 10656 | |
| 10653 | |
| 10652 | |
| 10651 | |
| 10650 | |
| 10649 | |
| 10648 | |
| 10646 | |
| 10645 |
Linux
리눅스 CD로 망가진 파일복구하기
|
| 10642 |
MySQL
25가지 sql 작성법
2
|
| 28809 |
HTML
union top n 가져오기
1
|
| 10641 | |
| 10638 |
JavaScript
이미지 테두리 없애기 스타일 시트
2
|
| 10637 | |
| 10636 |
JavaScript
window.open property | +JavaScript
|
| 10635 | |
| 28808 | |
| 10634 |
JavaScript
이메일 selectbox | +JavaScript
|
| 10632 |
JavaScript
[Javascript] 끊기지 않는 배너 롤링
1
|
| 28807 |
HTML
[자바스크립트] 오늘 날짜 함수
|
| 28806 |
HTML
[자바스크립트] 라디오 버튼 비활성
|
| 10631 |
JavaScript
[Javascript] id값 변수명으로 치환
|
| 10630 | |
| 10629 |
기타
무단링크 금지 스크립트
|
| 28805 | |
| 10627 |
JavaScript
상태바의 링크 주소 감추기
1
|
| 10626 | |
| 10625 | |
| 28804 | |
| 28803 |
HTML
프레임 소스보기 막기
|
| 10624 | |
| 10623 | |
| 28802 | |
| 10622 | |
| 10620 | |
| 10619 | |
| 10618 | |
| 10616 | |
| 10615 | |
| 10613 | |
| 10611 |
MySQL
서버 상태 값 주기적으로 메일로 발송하기
1
|
| 28799 | |
| 10610 |
JavaScript
이미지도용막기
|
| 10608 | |
| 28798 |
HTML
유용한 PHP성능 개선을 위한 팁
|
| 10604 |
JavaScript
작업창이 상단메뉴바까지 올라가서 옮길수 없을때..
3
|
| 28794 |
HTML
포토샵 화면이 좁을경우..
3
|
| 10602 | |
| 10600 | |
| 28793 | |
| 10596 | |
| 10595 |
JavaScript
리눅스 SendMail 속도 UP
|
| 10593 |
기타
폼 검증용 함수
1
|
| 28792 | |
| 28791 | |
| 28790 |
HTML
콤보박스 출력용 함수
|
| 10592 |
JavaScript
특정 확장자의 아이콘을 링크 테그형태로 만들어 주는 함수
|
| 28789 |
HTML
파일업로드 클래스~~
|
| 28787 |
HTML
날짜비교 함수
1
|
| 10591 |
JavaScript
자주사용하는 자바스크립트를 클래스로 묶어봤습니다.
|
| 10590 | |
| 10589 |
JavaScript
nylon 을 이용해 리눅스에서 sock4/5 운영하기
|
| 28785 | |
| 10588 |
JavaScript
Ajax강의- 두번째 강의의 pdf(프리젠테이션) 41-49
|
| 10587 | |
| 28783 |
HTML
테이블안에 있는 글 자동 정렬하기
1
|
| 10586 | |
| 28782 | |
| 10585 |
JavaScript
Ajax강의- 첫번째 강의의 pdf중 발표문건 51-60
|
| 10574 | |
| 10571 |
JavaScript
자신의 별자리
2
|
| 10570 |
JavaScript
Ajax강의- 첫번째 강의의 pdf중 발표문건 41-50
|
| 28778 | |
| 10568 | |
| 10567 | |
| 28777 | |
| 10564 |
기타
레이어안에 달력
2
|
| 10562 | |
| 10561 |
기타
채널모드로 윈도우 열기
|
| 28776 |
HTML
전체화면으로 페이지 열기
|
| 10559 |
JavaScript
여러가지 방법으로 창닫기
1
|
| 10558 | |
| 28775 | |
| 28774 | |
| 10557 |
JavaScript
가짜 카운터 달기
|
| 10556 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기