【发布时间】:2011-12-17 15:40:52
【问题描述】:
我正在使用 Big Commerce 平台开发一个网站。购物车页面内置于 PHP 调用的 sn-ps 中。我无权访问 PHP 文件。我需要做的是获取跨度标记的值(在给定索引处)并检索该值,我使用此值来确定我的 minQTY 文本字段应该是什么。我希望我的代码在页面加载后运行。但是我的脚本在页面上不起作用。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).load(function(){
$("a.CustomizeItemLink");
$changeIndex = $("a.CustomizeItemLink").index('a.CustomizeItemLink');
$change = $("a.CustomizeItemLink").length;
$productTestArray = ['/american-boxwood-buxus/', '/lavander-crape-myrtle-lagerstroemia-fs/']
$productLength = $productTestArray.length;
for(i=0, j=0; i<=$change, j<=$productLength; i++, j++){
$productTest = "http://www.tnnursery.net";
$productTestValue = $("td.blah a").get(i);
$productTest = "http://www.blah.net" + $productTestArray[j];
$MD = $productTestValue;
$MS = $productTest;
$minQTYArray = ['100','100','75','50','25','20','15'];
$cartSpanValue = $(".productAttributes td span:eq("+i+")").text();
$rdTestArray2 = ['6-12','12-18',"1-2'","2-3'","3-4'","4-5'","5-6'"];
$arr2Test = jQuery.inArray($cartSpanValue, $rdTestArray2);
$minQTYValue = $minQTYArray[$arr2Test];
$cartQtyValue = $(".qtyInput:eq("+i+")").val();
if($MD != $MS){
}
else{
if($cartQtyValue >= $minQTYValue){
}
else{
if ($arr2Test == -1){
$cartQtyValue = $(".qtyInput:eq(" + i + ")").val('100');
}
else{
$cartQtyValue = $(".qtyInput:eq(" + i + ")").val($minQTYValue);
alert($cartQtyValue);
}
}
}
}
});
});
});
</script>
</td>
<td class="ProductName" colspan="1">
<a href="http://www.blah.net/blah-blah-blah/">Item Name1</a><table class="productAttributes" cellpadding="0" cellspacing="2">
<tr>
<td>
<label>Plant​ Size​s:</label>
</td>
<td>
<span>12-18​"</span>
</td>
改变
28500
()
<div style="display: none" class="WrappingOptions">
Gift Wrapping:
<a href="#" onclick="Cart.ManageGiftWrapping('4eea86d587825');" style="">Add</a>
<span style="display: none">
(<a href="#" onclick="Cart.ManageGiftWrapping('4eea86d587825');">Change</a> or <a href="cart.php?action=remove_giftwrapping&item_id=4eea86d587825" onclick="return Cart.RemoveGiftWrapping();">Remove</a>)
</span>
<br />
<span style="display: none">
Gift Message:
</span>
</div>
</td>
<td align="center" class="CartItemQuantity">
<span style="padding: 0; margin: 0;"><input type="text" size="2" name="qty[4eea86d587825]" id="text_qty_4eea86d587825" class="qtyInput quantityInput" value="50"/></span>
<div style="">
<a href="cart.php?action=remove&item=4eea86d587825" onclick="Cart.RemoveItem('4eea86d587825'); return false;" class="CartRemoveLink">Remove</a>
</div>
</td>
我的问题是如何设置我的 jQuery 在 PHP 加载到页面后运行?
【问题讨论】:
-
什么意思? PHP 是一种服务器端语言,默认在 jQuery 运行之前“加载到页面中”。