'콤마'에 해당되는 글 3건

숫자 세자리마다 콤마를 표현하는 방법에 대해 알아보겠습니다.

:: ASP Script 에서 표현할 경우
    response.write(formatnumber( value, 0, -1 ))

:: PHP Script 에서 표현할 경우
    echo number_format($value);

:: Perl Script 에서 표현할 경우
    print cm($value);
    sub cm {
          my $num = shift;
          my ($n) = $num =~ /(\d+)/;
          1 while $n =~ s/(\d+)(\d{3})/$1,$2/;
          $num =~ s/(\d+)/$n/;
          $num;
    }

:: JSP 에서 표현할 경우
    new DecimalFormat("###,###,###,###,###").format(value);
    보통은 Bean으로 만들어서 표현을 합니다.

:: MS-SQL Query에 의해 표현할 경우
    SELECT
    REPLACE(CONVERT(VARCHAR,CONVERT(MONEY,1234567890),1),'.00','')
    결과값         
    1,234,567,890
    (1개 행 적용됨)
Posted by 아로스
<script type="text/javascript">

var s = commify(-1234567890.123);
document.write(s + '<br />');
// 출력 결과: -1,234,567,890.123


function commify(n) {
  var reg = /(^[+-]?\d+)(\d{3})/;   // 정규식
  n += '';                          // 숫자를 문자열로 변환

  while (reg.test(n))
    n = n.replace(reg, '$1' + ',' + '$2');

  return n;
}

</script>
Posted by 아로스

가격 콤마

Windows/JAVASCRIPT 2009. 4. 28. 19:11


<script>

function Set_Comma(n){
  return Number(String(n).replace(/\..*|[^\d]/g,"")).toLocaleString().slice(0,-3);
}
</script>
<BODY>
<FORM name="frm">
  
<input type="text" maxlength="20" name="amount" style=" text-align:right;" onkeyup="this.value = Set_Comma(this.value);">
</FORM>

Posted by 아로스
1

아로스

달력

05-05 13:43