Hi I am a newbe to php and I need to have the Dates on the list passed on to the two input values (Example Datefrom-Date list option - Dateto-Date list option) I am clueless on how to do this Thanks

see code below


<form id="form3" name="form3" action="">
<select name="SelectDate" id="SelectDate">
<option>Current Year</option>
<option>Current Year-to-date</option>
<option>Yesterday</option>
<option>Last Week</option>
<option>Last Week-to-date</option>
<option>Last Month</option>
<option>Last Month-to-date</option>
<option>Last Year</option>
<option>Last Year-to-date</option>
<option>Today</option>
<option>Current Month</option>
<option>Current Quarter</option>
<option>Current Quarter-to-date</option>
<option>All Dates</option>
</select>
from
<input name="Datefrom" type="text" id="Datefrom" value="<?php echo date("Y-01-01"); ?>" size="10" />

to
<input name="Dateto" type="text" id="Dateto" value="<?php echo date("Y-12-31"); ?>" size="10" />
<input type="submit" name="button2" id="button2" value="New date" />
</form>

I have tried with this and I am lost, I want to populate 2 Text field with dates (Datefrom and Dateto)


<?php

$SelectDate=$_GET;
switch ($SelectDate)
{
case "Current Year":
$CurrentYear="selected";
break;
case "Current Year-to-date":
$CurrentYearTD="selected";
break;
case "Yesterday":
$Yesderday="selected";
break;
case "Last Week":
$LastWeek="selected";
break;
case "Last Week-to-date":
$LastWeekTD="selected";
break;
case "Last Month":
$LastMonth="selected";
break;
case "Last Month-to-date":
$LastMonthTD="selected";
break;
case "Last Year":
$LastYear="selected";
break;
case "Last Year-to-date":
$LastYearTD="selected";
break;
case "Today":
$Today="selected";
break;
case "Current Month":
$CurrentMonth="selected";
break;
case "Current Quarter":
$CurrentQuarter="selected";
break;
case "Current Quarter-to-date":
$CurrentQuarterTD="selected";
break;
case "All Dates":
$AllDates="selected";
break;
}
?>

<form id="form3" name="form3" action="">
<select name="SelectDate" id="SelectDate">
<option value="">Current Year</option>
<option value="">Current Year-to-date</option>
<option value="">Yesterday</option>
<option value="">Last Week</option>
<option value="">Last Week-to-date</option>
<option value="">Last Month</option>
<option value="">Last Month-to-date</option>
<option value="">Last Year</option>
<option value="">Last Year-to-date</option>
<option value="">Today</option>
<option value="">Current Month</option>
<option value="">Current Quarter</option>
<option value="">Current Quarter-to-date</option>
<option value="">All Dates</option>
</select>
from
<input name="Datefrom" type="text" id="Datefrom" value="<?php echo date("Y-01-01"); ?>" size="10" />

to
<input name="Dateto" type="text" id="Dateto" value="<?php echo date("Y-12-31"); ?>" size="10" />
<input type="submit" name="button2" id="button2" value="New date" />
</form>

I have decided this way is better how do I populate the 2 text fields with dates
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.