我希望在现成的电子商务平台上触发多个添加到购物篮按钮。服务器使用以下脚本生成添加到购物篮按钮:
按钮 1:
<a id="productRepeater_ctl00_btnAddToBasket" class="btn addbutton" href="javascript:__doPostBack('productRepeater$ctl00$btnAddToBasket','')">add to basket</a>
按钮 2:
<a id="productRepeater_ctl01_btnAddToBasket" class="btn addbutton" href="javascript:__doPostBack('productRepeater$ctl01$btnAddToBasket','')">add to basket</a>
按钮 1:
<a id="productRepeater_ctl02_btnAddToBasket" class="btn addbutton" href="javascript:__doPostBack('productRepeater$ctl02$btnAddToBasket','')">add to basket</a>
平台脚本:
//<![CDATA[
var theForm = document.forms['buyoffpage'];
if (!theForm) {
theForm = document.buyoffpage;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
//]]>
我希望能够通过单击一个单独的 jQuery 按钮来提交所有这些按钮。到目前为止我得到的脚本只提交了第一个:
$("body").append('<div id=\"submitAll\"><a href=\"#\">HIT ME</a></div>');
$('#submitAll').click(function(e) {
__doPostBack('productRepeater$ctl00$btnAddToBasket', 'productRepeater$ctl01$btnAddToBasket','productRepeater$ctl02$btnAddToBasket');
});