Getting form info before submit button is clicked
Posted: Fri May 19, 2006 12:45 pm
I have a PayPal button that has two hidden fields. The first is the paypal email address to receive the money and the second is the amount to be sent. My problem is that I want to store the above two pieces of information in PHP variables and then use those variables as the values for the hidden fields. I don't know how to get the form's contents from the textboxes and move them into the PHP variables without first submitting the form.
The above is how I would normally get the contents of the textboxes after I submit the form, but I need the contents of the textboxes in those variables BEFORE I submit the form. My form code is below. I just have the basic form laid out right now because I don't even know what to try to get the above described to work. Thanks, Adam
Code: Select all
$email = $_POST['email'];
$rent = $_POST['rent'];Code: Select all
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<table border="0" rules="none" cellpadding="8" cellspacing="0">
<tr>
<td><font face="myriad"><b>Pay Rent To:</b></font></td>
<td>
//*********************************************************************************//
// This select control is dynamically loaded from the landlord names that are
// registered to receive online payments....
//*********************************************************************************//
echo('<select name="landlordSelect">');
// Run a loop and load the landlord selection box with the landlord names
for($i=1;$i<=$c;$i++){
?>
<option value="<?$landlord[$i];?>"><?echo $landlord[$i];?>
<?
}
echo('</select>');
?>
</td>
</tr>
<tr>
<td><font face="myriad"><b>Monthly Rent Amount:</b></font></td>
<td><input type="text" name="rent" size="10" maxlength="10"/></td>
</tr>
<tr><td align="center" colspan="2">
<!-- All of the below inputs except the pay button are from PayPal -->
<input type="hidden" name="cmd" value="_xclick">
<!-- the below button changes depending on the landlord selected -->
<input type="hidden" name="business" value="<?$email;?>">
<!-- the below button changes depending on the amount entered -->
<input type="hidden" name="amount" value="<?$rent;?>">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="bn" value="PP-BuyNowBF">
<input type="submit" name="submit" value="PAY RENT">
</td></tr>
</table>
</form></center>