I have the following to check weather a form field is populated or not. If the $priceperperson field is set then calculate the $rentalprice based on that, if its not, then calculate the $rental price based on the $baserentalprice.
$priceperperson = ($_POST['priceperperson']);
$baserentalprice = ($_POST['rentalprice']);
$numberofguests = ($_POST['numberofguests']);
if (isset($priceperperson)) {
$rentalprice = ($priceperperson * $numberofguests * $numberofnights);
} elseif (!isset($priceperperson)) {
$rentalprice = $baserentalprice;
}
UPDATE: My problem is that I dont seem to be able to set the rental price as $baserentalprice. The $priceperperson calculation works but when i delete the content of the $priceperperson field from the form and fire the ajax again, it wont work. Either way, its failing after the 'else'.