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
-
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?jon_brockman– jon_brockman2013年12月10日 01:34:08 +00:00Commented Dec 10, 2013 at 1:34
3 Answers 3
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
jon_brockman
3731 silver badge11 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Francesco
Yes, I needed on page load. This function work but the form submit on the same page so I have infinite loop
document.getElementById('shipping-zip-form').submit();
answered Dec 10, 2013 at 1:36
Barmar
789k57 gold badges555 silver badges669 bronze badges
Comments
You can use jQuery and try this :
$(document).ready(function(){
$('#send').click(function(){
$('#shipping-zip-form').submit();
});
});
Comments
lang-js