King King - 1 year ago 111
Javascript Question

Javascript - form submit not working

this is the code that isn't working:

<form id="paypal" name="paypal" action="" method="post" target="_parent" />Official website!
<input type="hidden" name="item_name" value="Donation">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="bn" value="PP-DonationsBF">
<input type="hidden" name="currency_code" id="currency_code" value="GBP" >
<input type="hidden" name="business" id="business" value="" >

<a href="javascript: donate(paypal);" class="button1"><span></span><strong>£<input name="amount" type="text" id="ppAmount" style="text-align:center;" value="5" size="2" /> Donate!</strong></a>
<input type="submit">
<div id="formtesting"></div>
<script type="text/javascript">

function donate(paypal) {

document.forms["paypal"].action = "";
document.getElementById("formtesting").innerHTML="did it work?";


I want it to submit when clicking on "button1", using "javascript: donate(paypal)" the submit button works fine..
(it prints "maybe" in the formtesting div but not "did it work?" :/)

Answer Source

Use this code it will work

function donate() {
document.paypal.action = "";
document.getElementById("formtesting").innerHTML="did it work?";

Here paypal is name of the form.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download