I searched before asking this question. I didn’t find an answer probably because I didn’t use the correct keywords while searching.
Anyways, here is what I’m faced with:
I want to sell tickets from a website. Each tickets costs $10. I’m using Paypal for receiving the payment. The html form consists of this:
<tr>
<td><label for="not">Number of Tickets</label></td>
<td><input name="not" type="text" id="not" /></td>
</tr>
<?php $total = $_POST['not']*10; ?>
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="xxx@xxxx.com">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="amount" value="<?php echo $total; ?>">
<input name="item_name" type="hidden" id="item_name" value="Ticket Purchase" />
<tr>
<td> </td>
<td><input type="submit" value="Pay" name="submit" />
</tr>
The problem is the total amount is to be calculated based on number of tickets being purchased. So if someone enters 5 tickets, the total should be $50 which will be used as value inside the ‘amount’ variable. But paypal isn’t taking the $total value. So I was wondering how should I go about posting a variable amount inside the ?
Thanks in advance,
Nisar
I think you would be better off calculating the total with javascript/jquery and update it that way.
If you change
to
then inside script brackets using jquery something like this
Although you still need to do data validation i.e. ensure that “not” is an integer.
Hope that helps.
Thanks
Nicholas