automated form submissions

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

automated form submissions

Post 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!
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Code: Select all

document.formName.submit();
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Post by kippy »

is it possible to use this without the onclick event handler?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

moved to client side.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post 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.
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Post 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....
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post 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 :)
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Post 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?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

superdezign wrote:I don't think you can fake posted variables in PHP... Sorry.
Yes, you can.
kippy
Forum Commoner
Posts: 84
Joined: Wed Jun 07, 2006 8:25 pm

Post by kippy »

how? I tried to place the $var1*$var2 into the form field and it doesn't make the trip to the destination...
Post Reply