I am modifying someone else's code to do this website and I am not sure how to do this correctly in html5 and php.
This is how it currently is.
/*------------------------------------------------------------------
Begin to find start/end times
NOTE: if s_date_time_opts is false we are editing all events and
there will not be any data to get
-------------------------------------------------------------------*/
if( $s_date_time_opts )
{
if( request_var('calAllDay', '') == "ON" )
{
$event_start_date = 0;
$event_end_date = 0;
$event_data['event_all_day'] = 1;
$event_data['event_day'] = sprintf('%2d-%2d-%4d', $date['day'], $date['month_no'], $date['year']);
$sort_timestamp = gmmktime( 0,0,0,$date['month_no'], $date['day'], $date['year']);
}
else
{
$start_hr = request_var('calHr', 0);
$start_mn = request_var('calMn', 0);
$event_start_date = gmmktime($start_hr, $start_mn, 0, $date['month_no'], $date['day'], $date['year'] ) - $user->timezone - $user->dst;
$sort_timestamp = $event_start_date;
$end_m = request_var('calMEnd', 0);
$end_d = request_var('calDEnd', 0);
$end_y = request_var('calYEnd', 0);
$end_hr = request_var('calHrEnd', 0);
$end_mn = request_var('calMnEnd', 0);
$event_end_date = gmmktime($end_hr, $end_mn, 0, $end_m, $end_d, $end_y ) - $user->timezone - $user->dst;
$event_data['event_all_day'] = 0;
$event_data['event_day'] = '';
// validate start and end times
if( $event_end_date < $event_start_date )
{
$error[] = $user->lang['NEGATIVE_LENGTH_EVENT'];
}
else if( $event_end_date == $event_start_date )
{
$error[] = $user->lang['ZERO_LENGTH_EVENT'];
}
}
$event_data['event_start_time'] = $event_start_date;
$event_data['event_end_time'] = $event_end_date;
$event_all_day = $event_data['event_all_day'];
$event_day = $event_data['event_day'];
}
/*------------------------------------------------------------------
End start/end times
-------------------------------------------------------------------*/
and an input field in the same php file
$all_day_check = "<input type='checkbox' name='calAllDay' value='ON' clicked='clicked' onclick='toggle_all_day_event()' />";
some javascript in the html file
function toggle_all_day_event()
{
if( document.postform.calAllDay.checked )
{
document.postform.calMEnd.disabled=true;
document.postform.calDEnd.disabled=true;
document.postform.calYEnd.disabled=true;
document.postform.calHr.disabled=true;
document.postform.calMn.disabled=true;
document.postform.calHrEnd.disabled=true;
document.postform.calMnEnd.disabled=true;
}
else
{
document.postform.calMEnd.disabled=false;
document.postform.calDEnd.disabled=false;
document.postform.calYEnd.disabled=false;
document.postform.calHr.disabled=false;
document.postform.calMn.disabled=false;
document.postform.calHrEnd.disabled=false;
document.postform.calMnEnd.disabled=false;
}
}
and some html further down in the html file
<fieldset class="fields1">
<dl style="clear: left;">
<dt><label>All Day Event:</label></dt>
<dd>{ALL_DAY_CHECK}</dd>
</dl>
</fieldset>
First off I would like the All Day Event checkbox currently on the page to be hidden and unchecked by default, or baring that unchecked and the disabled fields to be enabled and if checked later to disable the fields.
I thought I might be able to initialize the calAllDay variable earlier in the php file with this
// Intialize Calendar All Day Event to Off
$calAllDay = 'OFF';
and change the input checkbox to this
$all_day_check = "<input type='checkbox' name='calAllDay' value='ON' onclick='toggle_all_day_event()' />";
but the behavior of this sets the checkbox to unchecked (like I could live with) but the disabled fields in the form are still disabled untill I check the checkbox and then uncheck it again. I want the fields to be enabled on load.