I’m sure this is really easy, but I can’t get it to work
I’m trying to submit a form full of hidden fields automatically when the page loads. I don’t have access to the <body> tag, so I’m trying to add the auto submit with javascript. (jqeury)
I’ve got so far:
<form id="paypalpayment" name="paypalpayment" action="https://www.paypal.com/cgi-bin/webscr" method="post">
//bunch of hidden form fields
<input name="submit" type="submit" id="submit" value="Click to continue if you are not automatically redirected." />
</form>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("paypalpayment").submit();
});
</script>
But nothing happens…
Any suggestions?
btw this is within a wordpress page.
i’ve tried the regular “$(document).ready(function() {” as well.
I added a debug paragraph <p> and changed the javascript to:
$(document).ready(function() {
$(“paypalpayment”).submit();
$(“p”).text(“We are here”);
});
The last line of the javascript modifies the added debug paragraph without any troubles, suggesting the .submit() line isn’t causing an error, just does nothing.
load and ready event handlers tend to conflict allot… I wold suggest adding the load event to the element…
<form id=“paypalpayment” name=“paypalpayment” action=“https://www.paypal.com/cgi-bin/webscr” method=“post”>
//bunch of hidden form fields
<input name=“submit” type=“submit” id=“submit” value=“Click to continue if you are not automatically redirected.” />
</form>
I think you are editing in the design view… hence the <p></p> inserts in between your script tags… You might want to switch to code view and remove those tags…
Interesting, I wasn editing in HTML view not Visual view.
Anyway i’ve removed all line spaces from javascript code.
No error now, but still doesn’t work.