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

Captain Obvlious
20.2k5 gold badges50 silver badges83 bronze badges
asked Dec 10, 2013 at 1:28
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();
}
answered Dec 10, 2013 at 1:38
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();
answered Dec 10, 2013 at 1:36

Comments

0

You can use jQuery and try this :

 $(document).ready(function(){
 $('#send').click(function(){
 $('#shipping-zip-form').submit(); 
 });
});
answered Dec 10, 2013 at 1:56

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.