Page 1 of 1

automated form submissions

Posted: Wed Jul 25, 2007 11:49 am
by kippy
Was wondering, is it possible to have a form autosubmit? for example:

if i gather information on form A and send the information to a new page where I make a needed calculation for instance qty*price, then have a second form including my calculations submit automatically? Basically so that the user never sees the second form, it just appears to go through to proper page.

Thanks!

Posted: Wed Jul 25, 2007 12:18 pm
by miro_igov

Code: Select all

document.formName.submit();

Posted: Wed Jul 25, 2007 12:31 pm
by kippy
is it possible to use this without the onclick event handler?

Posted: Wed Jul 25, 2007 12:49 pm
by superdezign
I'm sure you could probably skip the second form altogether. Rethink the logic.

And this does not belong in the General Discussion forum.

Posted: Wed Jul 25, 2007 12:58 pm
by Burrito
moved to client side.

Posted: Wed Jul 25, 2007 1:47 pm
by miro_igov
Sometimes it is not possible to skip the second form. I recently made a script who saves a user input then redirects him to paypal web payments standard form with auto submit.

It is not possible to skip the auto submit because it needs to process the entry, save the data and decide if he should be transfered to paypal or not. And this should be made without second user confirmation.

I don't see any other ways but auto submit.

Posted: Wed Jul 25, 2007 1:50 pm
by kippy
miro hit it on the nose, m second form is submitting to paypal after I calculate and process a few things.. how did you accomplish this miro? If you don't mind me asking....

Posted: Wed Jul 25, 2007 2:04 pm
by superdezign
Then use the suggestion above. You can call it at any point. I'd do so directly after the form was created.

Code: Select all

<form name="toPayPal" method="post">
...
</form>
<script type="text/javascript">
document.toPayPal.submit();
</script>
I personally don't like using the document.formName format, but it's the easiest to understand.

Posted: Wed Jul 25, 2007 2:38 pm
by miro_igov
Hehe, only the PayPal like form submissions are designed so you first process the user input then make another form and submit it to paypal. Just made so much of this stuff and can feel pretty well what are you trying to do :)

Posted: Wed Jul 25, 2007 10:38 pm
by kippy
honestly, i think if i can get the $qty * $price to go in a set variable then I will be ok. any thoughts?

Posted: Wed Jul 25, 2007 10:47 pm
by superdezign
kippy wrote:honestly, i think if i can get the $qty * $price to go in a set variable then I will be ok. any thoughts?
I don't think you can fake posted variables in PHP... Sorry.

Posted: Wed Jul 25, 2007 11:31 pm
by feyd
superdezign wrote:I don't think you can fake posted variables in PHP... Sorry.
Yes, you can.

Posted: Wed Jul 25, 2007 11:33 pm
by kippy
how? I tried to place the $var1*$var2 into the form field and it doesn't make the trip to the destination...