js 오류 질문드립니다 채택완료
영카트 스킨 중 상품진열, 분류리스트에서 상품을 장바구니에 담는 스킨을 적용했는데
$option_item = get_list_options($row['it_id'], $row['it_option_subject'], $i);
해당코드에서 오류가 생기는것을 확인했습니다. 옵션을 불러오는 아래 두가지 스크립트에서 충돌오류가 나는것 같은데 해결방법이 있을까요? ㅜㅜ
include_once(str_replace(G5_URL, G5_PATH, G5_SHOP_CSS_URL).'/option.lib.php');
<script src="<?php echo G5_SHOP_CSS_URL; ?>/option.js"></script>

위에
$option_item = get_list_options($row['it_id'], $row['it_option_subject'], $i);
만 주석처리 하게되면 장바구니 담기라던가 상품이 출력되는데에는 전혀 문제가 없으나 상품 옵션 항목만 불러오고있지 못해서 옵션 불러오는 코드에 문제가 있는 것 같아요,,
답변 1개
채택된 답변
+20 포인트
1년 전
해당 오류는 jquery.min.js 파일이 제대로 호출해 오지 못해 스크립트 오류가 발생되는걸로 보여집니다.
로그인 후 평가할 수 있습니다
답변에 대한 댓글 6개
�
1년 전
head.sub에 jquery를 불러오고 있는데 해당코드의 문제일까요? 해당코드를 제외한 나머지 제이쿼리 관련 코드는 작동이 잘됩니다
�
1년 전
$ is not defined
Jquery is not defined
이렇게 에러가 나는건 스크립트 부분에 jquery 를 찾지 못해 발생되는 오류 입니다.
Jquery is not defined
이렇게 에러가 나는건 스크립트 부분에 jquery 를 찾지 못해 발생되는 오류 입니다.
�
1년 전
그러면 해당부분을 해결하려면 제이쿼리를 다시 넣어야하는건가요? head.sub에 jquery를 cdn으로 교체해서 넣었었는데 해결되지 않아서요..ㅜㅜ
�
1년 전
어느페이지에서 jquery를 호출하고 있는지 확인이 필요한데
지금 소스단에서는 list.php 파일과 shop.list.js 파일과 option.js 파일에서 오류가 나는걸로 보이는데 이것만 봐서는 정확한 답변을 드리기는 어렵습니다.
지금 소스단에서는 list.php 파일과 shop.list.js 파일과 option.js 파일에서 오류가 나는걸로 보이는데 이것만 봐서는 정확한 답변을 드리기는 어렵습니다.
�
1년 전
list.10.skin.php에서 option.js를 불러오고 있고
[code]
$(function() {
$("select.it_option").live("change", function() {
var $frm = $(this).closest("form");
var $sel = $frm.find("select.it_option");
var sel_count = $sel.size();
var idx = $sel.index($(this));
var val = $(this).val();
var it_id = $frm.find("input[name='it_id[]']").val();
// 선택값이 없을 경우 하위 옵션은 disabled
if(val == "") {
$frm.find("select.it_option:gt("+idx+")").val("").attr("disabled", true);
return;
}
// 하위선택옵션로드
if(sel_count > 1 && (idx + 1) < sel_count) {
var opt_id = "";
// 상위 옵션의 값을 읽어 옵션id 만듬
if(idx > 0) {
$frm.find("select.it_option:lt("+idx+")").each(function() {
if(!opt_id)
opt_id = $(this).val();
else
opt_id += chr(30)+$(this).val();
});
opt_id += chr(30)+val;
} else if(idx == 0) {
opt_id = val;
}
$.post(
"./itemoption.php",
{ it_id: it_id, opt_id: opt_id, idx: idx, sel_count: sel_count },
function(data) {
$sel.eq(idx+1).empty().html(data).attr("disabled", false);
// select의 옵션이 변경됐을 경우 하위 옵션 disabled
if(idx+1 < sel_count) {
var idx2 = idx + 1;
$frm.find("select.it_option:gt("+idx2+")").val("").attr("disabled", true);
}
}
);
} else if((idx + 1) == sel_count) { // 선택옵션처리
if(val == "")
return;
var info = val.split(",");
// 재고체크
if(parseInt(info[2]) < 1) {
alert("선택하신 선택옵션상품은 재고가 부족하여 구매할 수 없습니다.");
return false;
}
}
});
// 장바구니 담기버튼
$("button.btn_add_cart").click(function() {
var $frm = $(this.form);
// 메세지 레이어 닫기
cart_msg_layer();
set_option_value($frm, $(this));
});
// 장바구니 레이어 닫기
$("#cart_msg_close, #cart_msg_no").live("click", function() {
cart_msg_layer();
});
// 장바구니 이동
$("#cart_msg_yes").live("click", function() {
document.location.href = g5_shop_url+"/cart.php";
});
});
function set_option_value($frm, $btn)
{
var $sel = $frm.find("select.it_option");
var it_name = $frm.find("input[name^=it_name]").val();
var it_price = parseInt($frm.find("input[name^=it_price]").val());
var id = "";
var value, info, sel_opt, item, price, stock, run_error = false;
var option = sep = "";
if($sel.size() > 0) {
info = $frm.find("select.it_option:last").val().split(",");
$sel.each(function(index) {
value = $(this).val();
item = $(this).closest("tr").find("th label").text();
if(!value) {
run_error = true;
return false;
}
// 옵션선택정보
sel_opt = value.split(",")[0];
if(id == "") {
id = sel_opt;
} else {
id += chr(30)+sel_opt;
sep = " / ";
}
option += sep + item + ":" + sel_opt;
});
if(run_error) {
alert(it_name+"의 "+item+"을(를) 선택해 주십시오.");
return false;
}
price = info[1];
stock = info[2];
} else {
price = 0;
stock = $frm.find("input[name^=it_stock]").val();
option = it_name;
}
// 금액 음수 체크
if(it_price + parseInt(price) < 0) {
alert("구매금액이 음수인 상품은 구매할 수 없습니다.");
return false;
}
// 옵션 선택정보 적용
$frm.find("input[name^=io_id]").val(id);
$frm.find("input[name^=io_value]").val(option);
$frm.find("input[name^=io_price]").val(price);
// 장바구니 담기
$.post(
g5_shop_css_url+"/item.cartupdate.php",
$frm.serialize(),
function(error) {
if(error != "OK") {
alert(error.replace(/\\n/g, "\n"));
return false;
}
var cart_msg_layer = "";
cart_msg_layer += "<div id=\"cart_msg_layer\">";
cart_msg_layer += "<h3>장바구니 보기</h3>";
cart_msg_layer += "<button type=\"button\" id=\"cart_msg_close\"><span></span>닫기</button>";
cart_msg_layer += "<p>상품이 장바구니에 담겼습니다.<br><strong>지금 확인하시겠습니까?</strong></p>";
cart_msg_layer += "<div>";
cart_msg_layer += "<button type=\"button\" id=\"cart_msg_yes\"><img src=\""+g5_shop_css_url+"/img/pop_msg_yes.gif\" alt=\"예\"></button>";
cart_msg_layer += "<button type=\"button\" id=\"cart_msg_no\"><img src=\""+g5_shop_css_url+"/img/pop_msg_no.gif\" alt=\"아니오\"></button>";
cart_msg_layer += "</div>";
cart_msg_layer += "</div>
[/code]
[code]
$(function() {
$("select.it_option").live("change", function() {
var $frm = $(this).closest("form");
var $sel = $frm.find("select.it_option");
var sel_count = $sel.size();
var idx = $sel.index($(this));
var val = $(this).val();
var it_id = $frm.find("input[name='it_id[]']").val();
// 선택값이 없을 경우 하위 옵션은 disabled
if(val == "") {
$frm.find("select.it_option:gt("+idx+")").val("").attr("disabled", true);
return;
}
// 하위선택옵션로드
if(sel_count > 1 && (idx + 1) < sel_count) {
var opt_id = "";
// 상위 옵션의 값을 읽어 옵션id 만듬
if(idx > 0) {
$frm.find("select.it_option:lt("+idx+")").each(function() {
if(!opt_id)
opt_id = $(this).val();
else
opt_id += chr(30)+$(this).val();
});
opt_id += chr(30)+val;
} else if(idx == 0) {
opt_id = val;
}
$.post(
"./itemoption.php",
{ it_id: it_id, opt_id: opt_id, idx: idx, sel_count: sel_count },
function(data) {
$sel.eq(idx+1).empty().html(data).attr("disabled", false);
// select의 옵션이 변경됐을 경우 하위 옵션 disabled
if(idx+1 < sel_count) {
var idx2 = idx + 1;
$frm.find("select.it_option:gt("+idx2+")").val("").attr("disabled", true);
}
}
);
} else if((idx + 1) == sel_count) { // 선택옵션처리
if(val == "")
return;
var info = val.split(",");
// 재고체크
if(parseInt(info[2]) < 1) {
alert("선택하신 선택옵션상품은 재고가 부족하여 구매할 수 없습니다.");
return false;
}
}
});
// 장바구니 담기버튼
$("button.btn_add_cart").click(function() {
var $frm = $(this.form);
// 메세지 레이어 닫기
cart_msg_layer();
set_option_value($frm, $(this));
});
// 장바구니 레이어 닫기
$("#cart_msg_close, #cart_msg_no").live("click", function() {
cart_msg_layer();
});
// 장바구니 이동
$("#cart_msg_yes").live("click", function() {
document.location.href = g5_shop_url+"/cart.php";
});
});
function set_option_value($frm, $btn)
{
var $sel = $frm.find("select.it_option");
var it_name = $frm.find("input[name^=it_name]").val();
var it_price = parseInt($frm.find("input[name^=it_price]").val());
var id = "";
var value, info, sel_opt, item, price, stock, run_error = false;
var option = sep = "";
if($sel.size() > 0) {
info = $frm.find("select.it_option:last").val().split(",");
$sel.each(function(index) {
value = $(this).val();
item = $(this).closest("tr").find("th label").text();
if(!value) {
run_error = true;
return false;
}
// 옵션선택정보
sel_opt = value.split(",")[0];
if(id == "") {
id = sel_opt;
} else {
id += chr(30)+sel_opt;
sep = " / ";
}
option += sep + item + ":" + sel_opt;
});
if(run_error) {
alert(it_name+"의 "+item+"을(를) 선택해 주십시오.");
return false;
}
price = info[1];
stock = info[2];
} else {
price = 0;
stock = $frm.find("input[name^=it_stock]").val();
option = it_name;
}
// 금액 음수 체크
if(it_price + parseInt(price) < 0) {
alert("구매금액이 음수인 상품은 구매할 수 없습니다.");
return false;
}
// 옵션 선택정보 적용
$frm.find("input[name^=io_id]").val(id);
$frm.find("input[name^=io_value]").val(option);
$frm.find("input[name^=io_price]").val(price);
// 장바구니 담기
$.post(
g5_shop_css_url+"/item.cartupdate.php",
$frm.serialize(),
function(error) {
if(error != "OK") {
alert(error.replace(/\\n/g, "\n"));
return false;
}
var cart_msg_layer = "";
cart_msg_layer += "<div id=\"cart_msg_layer\">";
cart_msg_layer += "<h3>장바구니 보기</h3>";
cart_msg_layer += "<button type=\"button\" id=\"cart_msg_close\"><span></span>닫기</button>";
cart_msg_layer += "<p>상품이 장바구니에 담겼습니다.<br><strong>지금 확인하시겠습니까?</strong></p>";
cart_msg_layer += "<div>";
cart_msg_layer += "<button type=\"button\" id=\"cart_msg_yes\"><img src=\""+g5_shop_css_url+"/img/pop_msg_yes.gif\" alt=\"예\"></button>";
cart_msg_layer += "<button type=\"button\" id=\"cart_msg_no\"><img src=\""+g5_shop_css_url+"/img/pop_msg_no.gif\" alt=\"아니오\"></button>";
cart_msg_layer += "</div>";
cart_msg_layer += "</div>
[/code]
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인