943,169 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 22
  • PHP RSS
Aug 30th, 2010
0

keepin selected item in menu selected if onchange doesn't take effect

Expand Post »
i have a bookin system with a drop down menu for day, month, and year...

i have validated them so as to alert the user when entering in past dates. however it still keeps the value of the past date instead of keepin the current date.

this is a section of my code:

<?php

$date = time();

$day = date('d', $date);
$month = date('m', $date);
$year = date('Y', $date);

//We then determine how many days are in the current month
$days_in_month = cal_days_in_month(0, $month, $year);

$current_month = date('F');
echo $current_month;

?>

<script type="text/javascript">

function isValidDate()
{
var now = new Date();

//advance one day
now.setDate( now.getDate() + 1 );

var Day=document.getElementById('daysOfMonth').value;
var Month=document.getElementById('monthOfYear').value;
var Year=document.getElementById('year').value;

var str = Month + " " + Day + " " + Year;

var selectedDate= new Date(str);

if(selectedDate < now)
{
alert("You may not select dates in the past . . . only future days!!!");
}
}
</script>

<div id="Content" style="height:450px">
<table width="100%" border="0" cellpadding="6" td style="margin-bottom:30px">
<tr>
<td align="center">Coastal View B+B<div id="returnPage"><a href="http://www.coastalview.site11.com/Index.html" target="_self">Return to Coastal View Home Page</a></div></td>
</tr>
<tr style="background-image:url(images/UIHeaderBreak.jpg); background-repeat:repeat-x">
<td style="height:40px"></td>
</tr>
<tr>
<td style="height:40px; font-size:12px"><p align="center">Select the dates you would like to stay and then click the check availability button.
This will show you which rooms/units are free for the dates you have selected.</p></td>
</tr>
</table>
<form action="AvailableRooms.php" method="post" name="CheckAvailability" target="_self" id="CheckAvailability">
<table width="50%" border="0" cellpadding="6" align="center">
<tr>
<td><label for="daysOfMonth"></label>
<div align="right">
<select name="daysOfMonth" id="daysOfMonth" onchange="isValidDate()">
<option><?php echo $day + 1; ?></option>
<option>....</option>
<?php
for($i = 1; $i <= $days_in_month; $i++)
{
echo "<option value=".$i.">".$i."</option>";
}
?>
</select>
</div></td>
<td><label for="monthOfYear"></label>
<div align="center">
<select name="monthOfYear" id="monthOfYear" onchange="isValidDate()">
<option selected="selected"><?php echo $current_month; ?></option>
<option>........</option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>


any ideas???
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
gchurch is offline Offline
52 posts
since Aug 2010

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Calculate Hours & Minutes between two Dates/Time
Next Thread in PHP Forum Timeline: Struggling with ECHO command





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC