1

我真的需要一些关于如何在下一页(save.php)中传递返回日期值的帮助。我不能传递的值在这个“(输入类型='隐藏'名称='retDate [$i]'值='$retDate')”下。我在这个网站上使用日历日期选择器(http://www.triconsole.com/php/calendar_datepicker.php)。感谢有人可以帮助我解决这个问题,并在下面参考我的编码。

在“结果.php”下

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"></br>
    <h1>RESULT </h1>
    <p><b>Escalation Date : </b>
    <?php echo $_POST["date1"] ?> until <?php echo $_POST["date2"] ?>
    </p>
    <?php 
                 ......
            //Select database
            $selected = mssql_select_db($myDB, $link)
            or die("Couldn't open database $myDB");

            //declare the SQL statement that will query the database
            $query = "SELECT....."; 

        //execute the SQL query and return records
        if ($result = mssql_query($query, $link)){
            echo "<form name='form1' method='post' action='save.php'>";
            echo "<table border='1'>
            <tr>
            <th>batch_exception_id</th>
            <th>batch_id</th>
            <th>process_date_time</th>
            <th>Return Date</th>
            </tr>";
            $i=0;
            while ($row = mssql_fetch_assoc($result)) {   
                $rDate = $row['ReturnDate'];
                $beID = $row['batch_exception_id'];                         
                $proc_dt = $row['process_date_time'];
                echo "<tr>";
                echo "<td>" . $beID . "<input type='hidden' name='beID[$i]' value='$beID'/></td>";
                echo "<td>" . $row['batch_id'] . "</td>";
                echo "<td>" . $proc_dt . "<input type='hidden' name='procDT[$i]' value='$proc_dt'/></td>";

                if($rDate == ""){
                    echo "<td>";    
                            $f_name="retDate[".$i."]";    
                    $myCalendar = new tc_calendar($f_name, true, false);      
                    $myCalendar->setIcon("calendar/images/iconCalendar.gif");     
                    $myCalendar->setDate(date('d'), date('m'), date('Y'));    
                    $myCalendar->setPath("calendar/");    
                    $myCalendar->setYearInterval(2000, 2020);     
                    $myCalendar->dateAllow('2000-01-01', '2020-01-01');   
                    $myCalendar->setDateFormat('j F Y');      
                    $myCalendar->setAlignment('left', 'bottom');      
                    //$myCalendar->setSpecificDate(array("", "0", "0"), 0, 'year');   
                    //$myCalendar->setSpecificDate(array("0", "0"), 0, 'month');      
                    //$myCalendar->setSpecificDate(array("0"), 0, '');    
                    $myCalendar->writeScript();
                    echo "<input type='hidden' name='retDate[$i]' value='$retDate'/>";
                    //echo "<input type='hidden' name='retDate[$i]' value='".$myCalendar->getDate()."'/>";    
                    $i++;       
                    echo "</td>";
                } else {
                    echo "<td>" . $rDate . "</td>";
                }
                echo "</tr>";       
            }           

            echo "</table><br/>";
            echo "<input type='button' value='<<' onclick='history.back(-1)'/>";
            echo "<input type='hidden' name='total_rec' value='$i'/>";          
            echo "<input type='submit' value='Save'/>";         
            echo "<input type='button' value='Print' onclick='window.print()'/>";
            echo"</form>";
        }

        //close the connection
        mssql_close($link);     
    ?><br/>                 
</body>

在此处输入图像描述

在“save.php”下

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"></br>       
    <?php 
        //$ReturnDate = $_POST["rDate"];
        $arrbeID = $_POST["beID"];
        $tot_rec = $_POST["total_rec"];
        $arrprocDT = $_POST["procDT"]; 
        $arrretDate = $_POST["retDate"]; 

        for ($i=0; $i<$tot_rec;$i++) {
            echo "Batch Esc. ID: ".$arrbeID[$i]." 
                | Proc. DateTime: ".$arrprocDT[$i]."
                | Ret. Date: ".$arrretDate[$i]."
                <br>";
        }       

    ?><br/>
</body>

在此处输入图像描述

4

2 回答 2

0

我认为你需要这条线:

echo "<input type='hidden' name='retDate[$i]' value='$retDate'/>";

成为:

echo "<input type='hidden' name='retDate[$i]' value='$rDate'/>";

因为 $rDate 是您实际存储从数据库中获取的返回日期的位置:

$rDate = $row['ReturnDate'];
于 2012-04-14T05:35:20.827 回答
0

解决方案:-

将 Result.php 中的 sript 放在头部下方

    <link rel="stylesheet" title="Style CSS" href="cwcalendar.css" type="text/css" media="all" />
    <script type="text/javascript" src="calendar.js"></script>

在 Result.php 的正文下添加以下代码

     $date="date[".$i."]"; 
echo "<input type='text' name='date[$i]' id='$date' value=' ' onclick=\"fPopCalendar('".$date."')\">";  

脚本参考: http ://codetale.com/2009/06/21/javascript-calendar-widget-108/

于 2012-04-19T02:00:33.850 回答