/    Sign up×
Community /Pin to ProfileBookmark

Changing form action using drop down list

Hi Folks heres what im trying to do i have a form that allows usere to choosse there payment type (1) by cheque (2) by credit card these options are in a drop down list. what i was hoping for was that if they select credit card that it changes the form action to paypal.php or if they select cheque the action changes to cheque.html. SO IS THIS POSSIBLE HMMM.

here is what i have so fare :

<form action=”<?=$paymenttype?>” method=”post”>
<input type=”hidden” value=”Windows Hosting Plan” name=”item_name” />
<input type=”hidden” name=”no_shipping” value=”2″ />
<input type=”hidden” name=”no_note” value=”1″ />
<input type=”hidden” name=”currency_code” value=”EUR” />
<input type=”hidden” name=”lc” value=”IE” />
<input type=”hidden” name=”bn” value=”PP-BuyNowBF” />
<input type=”hidden” name=”cmd” value=”_xclick” />
<input type=”hidden” name=”business” value=”[email protected]” />
&nbsp;
<table width=”100%” border=”0″ cellpadding=”0″ cellspacing=”4″ bgcolor=”#E4EAF4″>
<tbody>
<tr>
<th></th>
<th><strong>Personal</strong> </th>
<th><strong>Basic</strong> </th>
<th><strong>Business</strong> </th>
<th><strong>Enterprise</strong> </th>
</tr>
<tr>
<td>Space </td>
<td>1Gb </td>
<td>2.5Gb </td>
<td>5Gb </td>
<td>10Gb </td>
</tr>
<tr>
<td>Transfer </td>
<td>10Gb </td>
<td>25Gb </td>
<td>50Gb </td>
<td>100Gb </td>
</tr>
<tr>
<td>Monthly </td>
<td>&euro;13.75 </td>
<td>&euro;20.95 </td>
<td>&euro;32.75 </td>
<td>&euro;48.75 </td>
</tr>
<tr>
<td>Annually </td>
<td>&euro;165.00 </td>
<td>&euro;251.40 </td>
<td>&euro;393.00 </td>
<td>&euro;585.75 </td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type=”radio” value=”165.00″ name=”amount” /></td>
<td><input type=”radio” value=”251.40″ name=”amount” /></td>
<td><input type=”radio” value=”393.00″ name=”amount” /></td>
<td><input type=”radio” value=”585.75″ name=”amount” /></td>
</tr>
<tr height=”60″>
<td>&nbsp;</td>
<td valign=”bottom” colspan=”4″></td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<table cellspacing=”0″ cellpadding=”0″>
<tr>
<td height=”27″ colspan=”2″>Enter your contact information. This is how our support can contact you if needed.</td>
</tr>
<input type=”hidden” value=”submit/signup/ci_info.sbm” name=”template_name” />

<tr>
<td height=”26″>First name</td>
<td><label>
<input name=”first-name” type=”text” size=”30″ />
</label></td>
</tr>
<tr>
<td height=”26″>Last name</td>
<td><input name=”last-name” type=”text” size=”30″ /></td>
</tr>
<tr>
<td height=”28″>Company</td>
<td><input name=”company” type=”text” size=”30″ /></td>
</tr>
<tr>
<td height=”27″>Address 1</td>
<td><input name=”address-line1″ type=”text” size=”30″ /></td>
</tr>
<tr>
<td>Address 2</td>
<td><input name=”address-line2″ type=”text” size=”30″ /></td>
</tr>
<tr>
<td height=”28″>City</td>
<td><input name=”city” type=”text” size=”30″ /></td>
</tr>
<tr>
<td height=”30″>County</td>
<td><select name=”county” size=”1″>
<option selected=”selected”>Select………</option>
<option>Carlow Co.</option>
<option>Cavan Co.</option>
<option>Clare Co.</option>
<option>Cork City</option>
<option>– Cork City North</option>
</select></td>
</tr>
<tr>
<td height=”27″>Postal Code</td>
<td><input name=”post-coade” type=”text” size=”30″ />
(If no post code, enter NA)</td>
</tr>

<tr>
<td height=”27″>Phone</td>
<td><input name=”phonenumber” type=”text” size=”30″ /></td>
</tr>
<tr>
<td height=”26″>e-mail</td>
<td><input name=”email” type=”text” size=”30″ /></td>
</tr>
</table>
<table cellspacing=”0″ cellpadding=”0″>
<tr>
<td width=”133″ height=”34″>Payment type</td>
<td width=”264″><label>
<select name=”paymenttype”>
<option value=”Select”>Please Select One</option>
<option value=”cheque.html”>Cheque</option>
<option value=”paypal.php”>Credit Card</option>
</select>
</label></td>
</tr>
<tr>
<td height=”29″>Billing Period</td>
<td><label>
<select name=”billingperiod”>
<option value=”Select”>Please Select One</option>
<option value=”1 Month”>1 Month</option>
<option value=”1 Year”>1 Year</option>
<option value=”2 Years”>2 Years</option>
<option value=”5 Years”>5 Years</option>
<option value=”10 Years”>10 Years</option>
</select>
</label></td>
</tr>
</table>
<p>&nbsp;</p>
<p><br />
<input name=”submit” type=”submit” onclick=”MM_validateForm(‘first-name’,”,’R’,’last-name’,”,’R’,’address-line1′,”,’R’,’city’,”,’R’,’phonenumber’,”,’RisNum’,’email’,”,’R’);return document.MM_returnValue” value=”Next …” />
</p>
</form>

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@chestertbJun 24.2007 — Have your form submit to a payments processing script.

<form action="makepayment.php" method="post">

The script payment.php then reads the variable payment type, and acts accordingly.

[code=php]$method = $_REQUEST['paymenttype'];

if($method=="paypal")
{
//assemble the paypal payment form and submit it
}
else
{
//assemble the cheque payment form
}[/code]


You could submit automatically using javascript, or you could have the user confirm their choice.

Note that by submitting your original form to a script, you get the opportunity to record the transaction before it goes to paypal, which may (or may not) be useful.

Cheers

CTB
×

Success!

Help @aiden857181 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...