Forum Moderators: coopster
If user selects a day, a form pops up an allows them to enter days info.
That works fine.
Info sent to mysql table.
When page reloads info displays on calendar ok.
My last thing to sort is...when they reclick a day they've entered info for, I want it to be able to already be there in the form that pops up.
The form is a static form, which is made visible/invisible on selecting the day. There is 1 form for all the days.
When you click it, is inputs the day/date into a hidden field which allows all the form info to be correctly saved into the mysql table.
[codes]
//#################################### SEARCH DATABASE FOR EXISTING INFO
//take the ALL from the rows of data for that login for this month
$searchdate = $year."-".$month."%";
$result = mysql_query("SELECT * FROM opt_cal WHERE x='$x' AND date LIKE '$searchdate' ") or die(mysql_error());
//Loop through to make new variable corresponding to date in database
while($row = mysql_fetch_array($result)){
$foo = $row['date'];
$foo="_".str_replace("-","",$foo);//take the "-" outta the date
//make an called the date
${$foo}=array($row['bookingstatus'],$row['storename'],$row['location'],$row['mileage'],$row['fee'],$row['invoicestatus']);
}
//LATER IN THE PAGE...Printing the calendar
//count up the days, until we've done all of them in the month
while ( $day_num <= $days_in_month )
{
echo "<td> <a href=\"optcal.php\" onclick=\"showTheForm('$day_num');return false;\">$day_num</a>";
//################ADD DATA INTO EACH TABLE CELL
$caldate = "_".$year.$month.$day_num;
$dayarray = ${$caldate};
if (is_array($dayarray))//if there's some data for this day, there will be an array.
{
echo $dayarray[1]; //the store name related to this date
}
echo "</td>"; //finish printing calendar bits.
//AND LASTLY the Jscript bit
function showTheForm(day) {
// get the form
var form = document.getElementById('daydetails');
var daychosen = document.getElementById('daychosen');
var dayconame = document.getElementById('coname');
// show the form
if(form.style.display == 'none')
{form.style.display = 'block';
// pass thru' the date clicked by user
daychosen.value=day;
//THIS IS THE BIT I CAN'T GET HEAD AROUND...HOW TO SET this form field value to the php variable corresponding to this day.
?dayconame.value="<?php echo "$_200902" ?>"+day+"[1]";
}
else if (form.style.display == 'block')
{form.style.display = 'none';}
}
[/codes]
Please help
But then he sets some other parameters hard-coded like +day+"[1] which I believe is an example. The $row['date'] has the date for the js to use but I do not see from the js code how this is processed.