1

actually I have:

<form action="<?php echo $this->getUrl('checkout/cart/estimatePost') ?>" method="post" id="shipping-zip-form" name="shipping-zip-form">
    <label for="postcode"<?php if ($this->isZipCodeRequired()) echo ' class="required"' ?>><?php echo $this->__('Zip/Postal Code') ?></label>
    <div class="input-box">
        <input class="input-text validate-postcode<?php if ($this->isZipCodeRequired()):?> required-entry<?php endif;?>" type="text" id="postcode" name="estimate_postcode" value="<?php echo "04000"; ?>" />
    </div>
    <div class="buttons-set">
        <button type="button" id="send" title="<?php echo $this->__('Get a Quote') ?>" onclick="coShippingMethodForm.submit()" class="button"><span><span><?php echo $this->__('Get a Quote') ?></span></span></button>
    </div>
</form> 

and I unsuccessful tried:

<script type="text/javascript">
    document.getElementById('send').submit();
document.forms['shipping-zip-form'].submit();

</script>

What I want to do it's quite simple, let javascript automatically press the button so submit the form. I will not need the submit button anymore, I need to automate the press button process. Thx

1
  • Can you be more specific about how you're automating the form submit? Is it supposed to submit on page load or on some other event? Commented Dec 10, 2013 at 1:34

3 Answers 3

1

I"m guessing that your function isn't firing. Set it to execute on page load if that's when you'd like it to happen. Also, only <form> elements can be submitted so trying to target your <button id="send"> won't work.

window.onload {
    document.getElementById('shipping-zip-form').submit();
}
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, I needed on page load. This function work but the form submit on the same page so I have infinite loop
1
document.getElementById('shipping-zip-form').submit();

Comments

0

You can use jQuery and try this :

   $(document).ready(function(){
   $('#send').click(function(){
           $('#shipping-zip-form').submit(); 
   });
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.