chrome加载我的页面,firefox没有

时间:2015-11-05 18:02:22

标签: php html google-chrome firefox

我正在尝试通过HTML表单(test_form.php - > test.php)在网页中回显php。该表单允许用户选择日期和时间。我将在下面显示test_form.phptest.php的代码。

这适用于Chrome(linux) - 我的脚本会检查日期和小时是否已设置,然后在浏览器中回显日期和小时。

但它在Firefox(linux)或Safari(Mac)中不起作用。

在Firefox中,我得到一个空白页面。当我查看页面源时,我看到了回显的东西 - 除了它告诉我没有设置日期和小时!

有没有人经历过这个?有没有人知道发生了什么?

提前感谢。

test_form.php:

<?php
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', '1');
?>
<!DOCTYPE html> 
<html>

<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1'> 
    <title>Select date a d/or time</title> 
    <link rel='stylesheet' href='http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css'>
    <link rel="stylesheet" href="http://cdn.jtsage.com/datebox/1.4.5/jqm-datebox-1.4.5.min.css" />
  <script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
    <script type="text/javascript" src="http://cdn.jtsage.com/external/jquery.mousewheel.min.js"></script>
    <script type="text/javascript" src="http://dev.jtsage.com/jQM-DateBox/js/doc.js"></script>
    <script type="text/javascript" src="http://cdn.jtsage.com/datebox/1.4.5/jqm-datebox-1.4.5.core.min.js"></script>
    <script type="text/javascript" src="http://cdn.jtsage.com/datebox/1.4.5/jqm-datebox-1.4.5.mode.calbox.min.js"></script>
    <script type="text/javascript" src="http://cdn.jtsage.com/datebox/1.4.5/jqm-datebox-1.4.5.mode.datebox.min.js"></script>
    <script type="text/javascript" src="http://cdn.jtsage.com/datebox/1.4.5/jqm-datebox-1.4.5.mode.flipbox.min.js"></script>
    <script type="text/javascript" src="http://cdn.jtsage.com/datebox/1.4.5/jqm-datebox-1.4.5.mode.slidebox.min.js"></script>
    <script type="text/javascript" src="http://cdn.jtsage.com/datebox/1.4.5/jqm-datebox-1.4.5.mode.customflip.min.js"></script>
    <script type="text/javascript" src="http://cdn.jtsage.com/datebox/i18n/jqm-datebox.lang.utf8.js"></script>
    <script type="text/javascript">
    jQuery.extend(jQuery.mobile,
    {
      ajaxEnabled: false
    });

 function checkForm(form)
  {
    // validation fails if the input is blank
    if(form.hour.value == "") {
      alert("Error: Please select an hour!");
      form.hour.focus();
      return false;
    }

    // regular expression to match only digits (0-24)
    var re = /0|(0[1-9])|(1[0-9])|(2[0-4]))/;

    // validation fails if the input doesn't match our regular expression
    if(!re.test(form.hour.value)) {
      alert("Error: Input contains invalid characters!");
      form.hour.focus();
      return false;
    }

    // validation was successful
    return true;
  }


    </script>
</head> 

<body> 

<div data-role='page'>
    <a href='#' data-rel='back' class='ui-btn ui-icon-back ui-btn-icon-notext ui-shadow ui-corner-all  ui-nodisc-icon ui-alt-icon ui-btn-inline'  data-role='button' role='button' data-inline='true'>Back</a>
    <a href='#popupNested' data-role='button' class=' ui-btn ui-shadow ui-corner-all ui-icon-bars ui-btn-icon-notext  ui-nodisc-icon ui-alt-icon ui-btn-inline' data-transition='turn' data-rel='popup' data-inline='true'>Date/time</a>

<div data-role='popup' id='popupNested' data-theme='none'>
    <div data-role='collapsibleset' data-theme='a' data-content-theme='a' data-collapsed-icon='arrow-r' data-expanded-icon='arrow-d' style='margin:0; width:250px;'>
        <div data-role='collapsible' data-inset='false'>
        <h2>Hourly</h2>
            <ul data-role='listview'>
                <li><a href='Manyhour_today_form.php' data-rel='dialog' data-role='date'>Pick an hour from today</a></li>
                <li><a href='Manyhour_form.php' data-rel='dialog'>Pick hour from previous day</a></li>
            </ul>
        </div><!-- /collapsible -->
        <div data-role='collapsible' data-inset='false'>
        <h2>Daily</h2>
            <ul data-role='listview'>
                <li><a href='Mtoday_POG.php'>So far today</a></li>
                <li><a href='Manyday_form.php' data-rel='dialog'>Choose a previous day</a></li>
            </ul>
        </div><!-- /collapsible -->
          <ul data-role='listview'>
                <li><a href='Manymonth_form.php' data-rel='dialog'>Monthly</a></li>
                <li><a href='Manyyear_form.php' data-rel='dialog'>Yearly</a></li>
            </ul>


    </div><!-- /collapsible set -->
</div><!-- /popup -->
    <div data-role='content' style='width:50%'>

                        <form action='test.php' method='post' onsubmit='return checkForm(this);'>
                        <label for'date'><strong>Select a date and hour</strong></label>
            <input type="text" name='date' data-role="datebox" data-options='{"mode":"calbox","calUsePickers": true, "calYearPickMin":2008, "calYearPickMax":"NOW", "beforeToday": true, "overrideDateFormat": "%Y-%m-%d"}'  placeholder='click icon to select date'/>

            <input type="text" name='hour' data-role="datebox" data-options='{"mode":"timeflipbox","minuteStep":60, "overrideTimeFormat": "%H", "overrideTimeOutput": "%H"}'  placeholder='click icon to select hour' required="required"/>

            <input type ='submit' name= 'submit' value='submit'>
           </form>
    </div>


</div><!-- /page -->

</body>
</html>

...和test.php:

<?php
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', '1');


if(isset($_POST['date']))
{
$date = $_POST['date'];$date = str_replace("-","",$date);echo "date IS set, and it is ".$date."<br>";
}
else {
$date = "20150101"; echo "date variable not set";
}

if(isset($_POST['hour']))
{
$hour = $_POST['hour']; echo "hour IS set! And it is ".$hour."<br>";
if($hour == "00"){$hour =24;}
} 
else {
$hour = "01"; echo "hour variable is not set";
}

?>

0 个答案:

没有答案