Citat:
Ursprungligen postat av allstars
har du mer än bara själva fältet i includefilen eller kan det vara något annat som gör att javascriptet går sönder?
|
Jag har en hel del annat där också, kom på nu att det kanske är att en annan javascriptfunction anropas på onclick i den filen? Jag har nämligen ett döljt fält som bara visas när checkboxen är iklickad. Kan säkert vara det som spökar till det?
Skickar i alla fall med hela koden här så kanske ni ser om det kan vara något annat som är problemet, men ska testa att ta bort onclick="showMe('hemlevDiv').
<?php
// -------- PHP STORE HOURS ---------
// ---------- Version 1.1 -----------
// -------- BY CORY ETZKORN ---------
// -------- coryetzkorn.com ---------
// -------- EDIT FOLLOWING SECTION ONLY ---------
// Set your timezone (codes listed at
http://php.net/manual/en/timezones.php)
// Delete the following line if you've already defined a timezone elsewhere.
date_default_timezone_set('Europe/Stockholm');
// Define daily open hours. Must be in 24-hour format, separated by dash.
$time_range_mon = '16:00-20:30';
$time_range_tue = '16:00-20:30';
$time_range_wed = '15:00-20:30';
$time_range_thu = '16:00-20:30';
$time_range_fri = '16:00-21:30';
$time_range_sat = '16:00-21:30';
$time_range_sun = '12:00-19:30';
// Place HTML for output here. Image paths or plain text (H1, H2, p) are all acceptable.
$closed_output = '<li class="textbox"><p align="left" style="text-align:left">Du kan tyvärr inte göra någon beställning just nu.</p></li>';
$open_output = '<li class="checkbox"><span class="name">Vill du ha din beställning levererad?</span>
<input name="leverans" type="checkbox" onclick="showMe(\'hemlevDiv\')" value="Leverans till" />
</li>
<div id="hemlevDiv" style="display:none;">
<li class="bigfield">
<input placeholder="Fullständig Adress" type="text" name="adress" /></li>
</div>';
// OPTIONAL: Output current day's open hours
$echo_daily_hours = false; // Switch to FALSE to hide numerical display of current hours
$time_output = 'g a'; // Enter custom time output format (options listed here:
http://php.net/manual/en/function.date.php)
$time_separator = ' - '; // Choose how to indicate range (i.e XX - XX, XX to XX, XX until XX)
// -------- END EDITING --------
// Gets current day of week
$status_today = date("D");
// Gets current time of day in 00:00 format
$current_time = date("G:i");
// Makes current time of day computer-readable
$current_time_x = strtotime($current_time);
// Builds an array, assigning user-defined time ranges to each day of week
$all_days = array("Mon" => $time_range_mon, "Tue" => $time_range_tue, "Wed" => $time_range_wed, "Thu" => $time_range_thu, "Fri" => $time_range_fri, "Sat" => $time_range_sat, "Sun" => $time_range_sun);
foreach ($all_days as &$each_day) {
$each_day = explode("-", $each_day);
$each_day[0] = strtotime($each_day[0]);
$each_day[1] = strtotime($each_day[1]);
}
// Defines array of possible days of week
$week_days = array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun");
// Compares current day of week to possible days of week and determines open vs closed output based on current day and time.
foreach ($week_days as &$each_week_day) {
if ($status_today == $each_week_day) {
echo '<div class="open-closed-sign">';
if (($all_days[$each_week_day][0] <= $current_time_x) && ($all_days[$each_week_day][1] >= $current_time_x)) {
echo $open_output;
} else {
echo $closed_output;
}
if ($echo_daily_hours) {
echo '<br /><span class="time_output">';
echo date($time_output, $all_days[$each_week_day][0]) . $time_separator . date($time_output, $all_days[$each_week_day][1]);
echo '</span>';
}
echo '</div>';
}
}
?>