<div class="buttons"> <a href="#" class="btn btnGreen"><span>Beta Signup</span></a> <span><em>or</em></span>
<a onclick="test()" class="btn btnBlue"><span>Donate to Development</span></a> </div>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="JZDSU6T647PL4">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div>
当我点击捐赠给开发按钮时,我希望表单中的操作发生,我怎么能这样做?我想从btn btnblue类中成像,但它不会转移到表单
答案 0 :(得分:1)
你需要创建一个通过javascript提交表单的函数。例如
<a onclick="submit()" class="btn btnBlue"><span>Donate to Development</span></a>
function submit() {
var form = document.querySelector('form');
if(whatever){
form.submit();
}
}
答案 1 :(得分:1)
<a onclick="test()" class="btn btnBlue"><span>Donate to Development</span></a>
<script>
function test() {
var form = document.querySelector('form'); if(whatever){
form.submit();
} }
</script>
创建JavaScript函数
答案 2 :(得分:1)
如果您不做任何其他事情而不仅仅是提交表单,那么您不需要任何功能。
<div class="buttons"> <a href="#" class="btn btnGreen"><span>Beta Signup</span></a> <span><em>or</em></span>
<a onclick="document.getElementById('form1').submit(); return false;" class="btn btnBlue"><span>Donate to Development</span></a> </div>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" id="form1">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="JZDSU6T647PL4">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div>