230049 와 같은 숫자를 변환수준(type)에 따라서 다음의 형태로 변환하는 메소드
HIGH - 이십삼만 사십구
HALF - 2십3만 49
LOW - 23만 49
method signiture
number2Kor( string number, string type, string delim);
주어진 숫자 형태의 문자열 number 를 입력받아서 type 에 따라서 한글 형태로 변환함. 4자리마다 주어진 delim 문자열을 삽입.
properity list
number ( string , required )
변환할 숫자 형태의 string 값.
type ( string, optional, default = "HIGH")
다음의 세가지 값 중 하나.
- number2Kor.HIGH : 숫자와 모든 단위를 전부 한글로 변환 ( 23003 => 이만 삼천 삼)
- number2Kor.HALF : 숫자만 한글로 변환 ( 23003 => 2만 3천 3)
- number2Kor.LOW : 단위만 붙임 (23003 => 2만 3003 )
기본값은 "HIGH"로 전부 한글로 변환.
delim ( string, optional , default = " " )
숫자 4자리마다 삽입될 구분용 문자. 기본값은 " ".
예제.
<script type="text/javascript">
function process() {
var type = getSelectedType();
var numberString = document.getElementById("num").value;
var value = number2Kor( numberString , type );
document.getElementById("output").innerHTML = value + "원";
}
function getSelectedType ( ) {
var types = document.getElementsByName("typeVal");
var value;
for(var i = 0; i < types.length; i++){
if(types[i].checked){
return types[i].value;
}
}
throw "no valid type value";
}
</script>
<script type="text/javascript" src="num-to-kor.js"></script>
</head>
<body>
<input type="radio" name="typeVal" value="HIGH" checked="checked">HIGH
<input type="radio" name="typeVal" value="HALF">HALF
<input type="radio" name="typeVal" value="LOW">LOW
<input id="num" type="text" value="1000000020000" />
<input type="button" value="Transform" onclick="process()"/>
<div id="output"></div>
'Dev' 카테고리의 다른 글
[ Mybatis ] DB 설정 정보 분리 (0) | 2014.05.03 |
---|---|
[HTML5] Html5 강좌 동영상 (0) | 2011.03.25 |
FireFox 브라우저에서 캐쉬기능 설정 (0) | 2011.02.08 |