php 숫자값 출력방식에 대해 질문합니다.

php 숫자값 출력방식에 대해 질문합니다.

QA

php 숫자값 출력방식에 대해 질문합니다.

본문

php 숫자값 출력방식에 대해 질문합니다.

아래 '시중가격' 부분에서 출력한 방식 처럼 '판매가격' 부분에서도 input 태그를 사용하지 않고 출력하고 싶습니다.
'시중가격'에 cust_amount 부분을 '판매가격'에서 sell_amount로 바꿔서 해보니 값이 0으로만 출력됩니다.

 

아래 부분에 가격에 대한 함수 정의를 써놓았습니다.

 

php, 자바에 잘 알지 못해서... 방법을 모르겠네요ㅜ 도움부탁드립니다!



<? if ($this->itemInfo[cust_amount]) { // 1.00.03 ?>
                <tr height=25>
                    <td>    · 시중가격</td>
                    <td align=center>:</td>
                    <td><?=number_format($this->itemInfo[cust_amount])?> 원</td>
                </tr>
                <tr><td colspan=3 height=1 background='<?=$gConf['TEMPLATE_URL']?>/image-shop/dot_line.gif'></td></tr>
                <? } ?>
<?
 //print_r($this->itemInfo);
?>
                <tr height=25>
                    <td>    · 판매가격</td>
                    <td align=center>:</td>
                    <td><input type=text name=disp_sell_amount size=12 style='text-align:right; border:none; border-width:0px; font-weight:bold; width:80px; font-family:Tahoma;'  readonly > 원
                        <input type=hidden name=m_it_amount value='0'>
                    </td>
                </tr>
                <tr><td colspan=3 height=1 background='<?=$gConf['TEMPLATE_URL']?>/image-shop/dot_line.gif'></td></tr>
 
/////////////////////////////////////////////////생략//////////////////////////////////////////////////////////
 
function amount_change()
{
    var member_amount = parseInt('<?=$this->itemInfo[amount2]?>'); 
    var special_amount = parseInt('<?=$this->itemInfo[amount3]?>'); 
    var basic_point  = parseFloat('<?=$this->itemInfo[point]?>');
    var cust_amount  = parseFloat('<?=$this->itemInfo[cust_amount]?>');
 var basic_amount;
    var f = document.fitem;
    var opt1 = 0;
    var opt2 = 0;
    var opt3 = 0;
    var opt4 = 0;
    var opt5 = 0;
    var opt6 = 0;
    var ct_qty = 0;
    
//시중가격,회원가격,특별가격순으로
 if(cust_amount > 0) basic_amount = cust_amount;
 if(member_amount > 0) basic_amount = member_amount;
 if(special_amount > 0) basic_amount = special_amount;

    if (typeof(f.ct_qty) != 'undefined')
        ct_qty = parseInt(f.ct_qty.value);
    if (typeof(f.it_opt1) != 'undefined') opt1 = get_amount(f.it_opt1.value);
    if (typeof(f.it_opt2) != 'undefined') opt2 = get_amount(f.it_opt2.value);
    if (typeof(f.it_opt3) != 'undefined') opt3 = get_amount(f.it_opt3.value);
    if (typeof(f.it_opt4) != 'undefined') opt4 = get_amount(f.it_opt4.value);
    if (typeof(f.it_opt5) != 'undefined') opt5 = get_amount(f.it_opt5.value);
    if (typeof(f.it_opt6) != 'undefined') opt6 = get_amount(f.it_opt6.value);
    var amount = basic_amount + opt1 + opt2 + opt3 + opt4 + opt5 + opt6;
    var point  = parseInt(basic_point);
    if (typeof(f.m_it_amount) != 'undefined')
        f.m_it_amount.value = amount;
    if (typeof(f.disp_sell_amount) != 'undefined')
        f.disp_sell_amount.value = number_format(String(basic_amount * ct_qty));
    if (typeof(f.disp_cust_amount) != 'undefined')
        f.disp_cust_amount.value = number_format(String(cust_amount * ct_qty));
    if (typeof(f.it_point) != 'undefined') {
        f.it_point.value = point;
        f.disp_point.value = number_format(String(point * ct_qty));
    }
}
 

이 질문에 댓글 쓰기 :

답변 1

이건 영카트 코드가 아닌데요?

 

<td><input type=text name=disp_sell_amount size=12 style='text-align:right; border:none; border-width:0px; font-weight:bold; width:80px; font-family:Tahoma;'  readonly > 원 <---이부분 말씀이죠?


수정

<td><input type='hidden' name='disp_sell_amount' value=''>

 <span id='sell_amount'> </span>원

 


자바스크립트 마지막부분에 추가

  document.getElementById('sell_amount').innerHTML = number_format(String(basic_amount * ct_qty)); 

 

jquery사용중이라면 $('#sell_amount').html(number_format(String(basic_amount * ct_qty)));

 

 

 


 

답변을 작성하시기 전에 로그인 해주세요.
전체 125,873 | RSS
QA 내용 검색

회원로그인

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