shop.js 질문 드립니다.

shop.js 질문 드립니다.

QA

shop.js 질문 드립니다.

답변 3

본문

특정 카테고리 ca_id=30 에만 아래 소스중 '총 금액' 이란 텍스트 대신에 ' 총 공사비'로 나오게 하고 싶은데 어떻게 하면 될까요.

 

js/shop.js


// 가격계산
function price_calculate()
{
    var it_price = parseInt($("input#it_price").val());
    if(isNaN(it_price))
        return;
    var $el_prc = $("input.io_price");
    var $el_qty = $("input[name^=ct_qty]");
    var $el_type = $("input[name^=io_type]");
    var price, type, qty, total = 0;
    $el_prc.each(function(index) {
        price = parseInt($(this).val());
        qty = parseInt($el_qty.eq(index).val());
        type = $el_type.eq(index).val();
        if(type == "0") { // 선택옵션
            total += (it_price + price) * qty;
        } else { // 추가옵션
            total += price * qty;
        }
    });
    $("#sit_tot_price").empty().html("<span>총 금액 :</span> "+number_format(String(total))+"원");
}

이 질문에 댓글 쓰기 :

답변 3

해당 총 금액 부분을 수정해주시면 됩니다.

그리고 브라우저의 캐시를 삭제 해주시거나 shop.js를 불러오는 부분에 ?ver=1 등 임의의 변수를 붙여서 브라우저에서 수정 된 버전으로 불러올 수 있게 해주시면 됩니다

function price_calculate(a){

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

if(a){

$("#ca_id").empty().html("<span>총 공사비 :</span> "+number_format(String(total))+"원");

}

 

}


function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, "\\$&");
    var regex = new RegExp("[?&]" + name + "(=([^]*)|&|#|$)"),
        results = regex.exec(url);
    return results[2];
}
function price_calculate(){
..
var url = window.location.href;
var ca_id = getParameterByName('ca_id', url);
if(ca_id=="30")
 $("#ca_id").empty().html("<span>총 공사비 :</span> "+number_format(String(total))+"원");
else
 $("#sit_tot_price").empty().html("<span>총 금액 :</span> "+number_format(String(total))+"원");
..
}
답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 4
© SIRSOFT
현재 페이지 제일 처음으로