I have two date textfields who are popolated by a javascript (pop up calendar where you pick the date and the date populates the text field.) Under those I have a dynamic PHP text that calculates the days between the two dates.
I currently use the update (Submit) button on the form to activate the PHP code that calculates the days between.
Is it possible to write the code so it automatically changes the "Days between:" value when the last text field has been populated so that people can see how many days it is between the two dates BEFORE they push the submit button.?! Excuse my bad english i`m norwegian
My PHP code if anyone needs it:
<?PHP
$dateRegExp = "#^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{2,4})$#ies";
$timestamp1 = preg_replace( $dateRegExp, "mktime(0, 0, 0, '\\2', '\\1', '\\3')", $_POST["txtAnk"] );
$timestamp2 = preg_replace( $dateRegExp, "mktime(0, 0, 0, '\\2', '\\1', '\\3')", $_POST["txtAvr"] );
$dateDiff = $timestamp2 - $timestamp1;
$test = floor(dateDiff/60/60/24);
echo 'Du ønsker å reservere '. floor($dateDiff/60/60/24). ' dag(er).';
echo '<br />Du ønsker å reservere '. ($test). ' dag(er).';
?>
Update text onChange
Moderator: General Moderators