我有一个Ajax Submit按钮,显示消息已成功添加。单击添加到购物车按钮时查看购物车。现在成功添加。并且查看购物车消息显示为单个按钮。有没有办法分离出成功添加和查看购物车按钮?
添加到购物车按钮代码:
<fieldset class="add-to-cart-box">
<legend><?php echo $this->__('Add to Cart') ?></legend>
<?php if(!$_product->isGrouped()): ?>
<input name="qty" type="hidden" class="input-text qty" id="qty" maxlength="12" value="1" /></span>
<?php endif; ?>
<button class="form-button" onclick="ajaxSubmit('<?php echo $this->getAddToCartUrl($_product) ?>', this)"><span><?php echo $this->__('Add to Cart') ?></span></button>
</fieldset>
成功添加。查看购物车消息和按钮代码:
<script type="text/javascript">
function ajaxSubmit(url, button){
var pars = '';
var target = '';
var myAjax = new Ajax.Updater(target,url, {method: 'get', parameters: pars});
button.innerHTML = '<span>Successfully Added. View Cart</span>';
button.className = 'form-button-alt';
button.style.marginTop = '6px';
button.attributes["onclick"].value = 'setLocation(\'/checkout/cart/\')';
}
</script>
答案 0 :(得分:0)
您正在替换内部按钮html
button.innerHTML = '<span>Successfully Added. View Cart</span>';
而是用两个按钮实例替换按钮