How to display two buttons with Ajax on Submit

I have a Ajax Submit button which shows up with a message Successfully Added. View Cart when clicked on Add to cart button. Right now Successfully Added. and View Cart message is show as a single button. Is there any way to separate out Successfully Added and View Cart button?

Add to cart button code:

<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>

Successfully Added. View Cart message and button code:

<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>

Answers


you are replacing the inner button html

 button.innerHTML = '<span>Successfully Added. View Cart</span>';

instead replace the button with two button instances


Need Your Help

How to access external mysql database in wamp server on my windows desktop from my raspberry pi using python script?

python mysql database raspberry-pi wampserver

I am working on a project which includes sensing gas particles from mq6 sensor and attain approx. readings from it and send those readings to the mysql database in wamp server on my windows desktop...

h:commandButton remains disabled even after changing disabled to true and re-rendering it using a4j:commandButton

jsf commandbutton disabled-control

I have a page with an inputtextwhere I type the name of an author to search for, when I click the a4j:commandButton searchButton, I'd like to enable the h:commandButton GoToBUtton, if the search re...