In my PHP site, I am trying to get a button to redirect to a PayPal page for payment if a user has chosen PayPal from the dropdown. Normally, the button would go to the next page to authorize the credit card payment, but since the addition of PayPal, I need that button to redirect only if PayPal is chosen, otherwise it should still go to the next page in the payment process.
Can someone help me make my code work? I'm not very experienced, so I appreciate any help.
<tr>
<td class="required req_poss" colspan="2">
<label>Card Type <span>*</span>
<select name="CardType" id="CardType">
<option value="" selected="selected">--Please Select--</option>
<option value="Amex">American Express</option>
<!--<option value="Discover">Discover</option>-->
<option value="MasterCard">MasterCard</option>
<option value="PayPal">PayPal</option>
<option value="Visa">Visa</option>
</select>
</label>
</td>
</tr>
<tr>
<td colspan="2" align="right"><br />
<button type="button" class="prev" style="float:left">« Back</button>
<button type="button" class="next right">Proceed »</button>
</td>
</tr>
What I want is something like this:
<script type="text/javascript">
if ($('#CardType').val() == 'PayPal'){
$('next').click(window.location.href = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=BUSINESSNAME");
}
</script>