Forum Moderators: coopster
I wish to have a simple multi-dropdown donate option, the user selects a pre-defined amount from dropdown1 then they choose the payment gateway (paypal, stormpay, e-gold, intgold etc) from dropdown2, then click Go!
However, each of these gateways code is embeded on the page as a form (as buttons, no input required).
Is there a way to use a "master" form in php, which selects between multiple other "slave" forms via a dropdown select and submits that value?
I also need a dynamic "payment amount" as dropdown menu (or text input) menu which inserts its value (amount to donate) anywhere on the page as a dynamic php include... (including form value fields) so when the master form is submitted, the "payment amount" include will refresh the value within any of the sub forms vaules upon submitting the MASTER form.
Tough question, i know... is it possible?
Cheers, ReBeAt:)
PHP just takes the stuff that the form produces, rehashes it, and makes more output - either to the same form with things changed in it, or to the database, or to a payment provider - or to all three - but the nuts and bolts of what you're asking have more to do with the forms themselves. If it can be spit out in the form of HTML or javascript, that's not really a problem for PHP - PHP will be able to handle it fine - but you will need to get to know your form types, since PHP has no built-in functions for producing forms.
you might want to check with the various payment providers as well, often you can use a query string ($_GET method) as well as the hidden form. This would allow you to submit the form with their selections and then construct the query string t submit and then redirect, using the header function, to the appropriate provider.
It doesn't really matter if it is javascript or php.. i just assumed php was more XPSP2 friendly (script blocking) i also thought php could insert itself as an include anywhere in the html (be it text, a form value, a textarea etc)
Anyway, i am not sure where to start.. i have a script which parses a forms values, but not sure if it is suitable.
Cheers and thanks again for the help.. much appreciated.
REbeAt
[edited by: coopster at 3:03 pm (utc) on Nov. 3, 2004]
[edit reason] removed link per TOS [webmasterworld.com] [/edit]
imagine a form with two dropdowns, the first one is a amount dropdown which has $5, $10, $20.. the next dropdown (donation gateway) selects between paypal, stormpay or intgold, then a submit button. These gateways are actually hidden forms within the page (this is required due to the several "pre-defined" variables required by these gateways to work).
Ideally, the "amount" value would insert itself as include on the fly (upon submit) into these gateway forms name="amount" value="<include here>" field. Then upon submit, that gateway (or sub form) will be submitted (via an onClick button or other method?).
Another way, but not sure if this is possible, could i use a script within each gateway dropdown entry to include the entire form there? ie: "something" like:
<form name="donate" onSubmit="return submit_form(this)">
<select name="amount" onSelect="<?php value?>>
<option value="include_5">$5</option>
<option value="include_10">$10</option>
<option value="include_20">$20</option>
</select>
<select name="gateway">
<option value="submit_form_name_paypal" onSelect="<form action=https://www.paypal.com/cgi-bin/webscr method=post name=paypal id=paypal target=_blank><input type=hidden name=amount value=<?php echo(amount)?>><input type=hidden name=currency_code value=USD>">
<option value="submit_form_name_stormpay" onSelect="?">
<option value="submit_form_name_intgold" onSelect=?">
<input type="button" value="Submit" onSubmit="<?php include(amount); submit?>">
</form>
I understand the above code is ""totally"" wrong...lol ;) -but is this method possible? if so how can i make it "work"?
The other way (but a lot more work) would be to store (as a cookie) the amount value then upon submit goes to *individual* payment pages... paypal.php?amount=, stormpay.php?amount=, intgold.php?amount= etc (maybe this can be achieved with php on the fly by including the the gateway form content hidden by php?) and auto insert this cookie as an echo into the individual gateway pages/forms (i am new to php so pls forgive cluelessnessness).
I am at a loss of how to start, i'd prefer to use php due to its browser friendlyness (XPSP2) ...but don't have a problem with javascript.
Cheers, rebeat