변수값 콤마 부여하기

변수값 콤마 부여하기

QA

변수값 콤마 부여하기

본문

3552902211_1637136252.8388.png

 

아래 코드를 사용해서 위의 것을 구현했습니다.

위에 30,000이런식으로 넣고 싶은데

변환하는 숫자에는 콤마가 안나타나더라구요.

혹시 어떻게 하면 될까욤?

 


<!-- Range Slider CSS -->
<link rel="stylesheet" href="../css/pay_style.css">
<!--Only for demo purpose - no need to add.-->
<link rel="stylesheet" href="../css/pay_demo.css" />
 
<section>
    <div class="rt-container">
        <div class="col-rt-12">
            <div class="Scriptcontent">
 
                <!-- Range Slider HTML -->
                <div slider id="slider-distance">
                    <div>
                        <div inverse-left style="width:70%;"></div>
                        <div inverse-right style="width:70%;"></div>
                        <div range style="left:30%;right:40%;"></div>
                        <span thumb style="left:30%;"></span>
                        <span thumb style="left:60%;"></span>
                        <div sign style="left:30%;">
                            <span id="value" class="min_value">30000</span>
                        </div>
                        <div sign style="left:60%;">
                            <span id="value" class="max_value">60000</span>
                        </div>
                    </div>
                    <input type="range" id="min_input" tabindex="0" value="30000" max="100000" min="0" step="1" oninput="
  this.value=Math.min(this.value,this.parentNode.childNodes[5].value-1);
  var value=(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.value)-(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.min);
  var children = this.parentNode.childNodes[1].childNodes;
  children[1].style.width=value+'%';
  children[5].style.left=value+'%';
  children[7].style.left=value+'%';children[11].style.left=value+'%';
  children[11].childNodes[1].innerHTML=this.value;" />
 
                    <input type="range" id="max_input" tabindex="0" value="60000" max="100000" min="0" step="1" oninput="
  this.value=Math.max(this.value,this.parentNode.childNodes[3].value-(-1));
  var value=(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.value)-(100/(parseInt(this.max)-parseInt(this.min)))*parseInt(this.min);
  var children = this.parentNode.childNodes[1].childNodes;
  children[3].style.width=(100-value)+'%';
  children[5].style.right=(100-value)+'%';
  children[9].style.left=value+'%';children[13].style.left=value+'%';
  children[13].childNodes[1].innerHTML=this.value;" />
                </div>
                <!-- End Range Slider HTML -->

 
            </div>
        </div>
    </div>
</section>

 
<script>
    function numberWithCommas(x) {
        return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
    }
 
    var pay_value = $('#value').html();
 
    pay_value = numberWithCommas(pay_value);
 
    $('#value').html(pay_value);

 
</script>
<!-- Analytics -->

 

 

이 질문에 댓글 쓰기 :

답변 1


<div sign style="left:30%;">
    <span id="value1" class="min_value">30000</span>
</div>
<div sign style="left:60%;">
    <span id="value2" class="max_value">60000</span>
</div>
 

 


<script>
function numberWithCommas(x) {
  return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
$('#value1').html(numberWithCommas($('#value1').html()));
$('#value2').html(numberWithCommas($('#value2').html()));
</script>
답변을 작성하시기 전에 로그인 해주세요.
전체 354
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT