Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在php表单上添加多个带日期的行_Php_Datepicker - Fatal编程技术网

在php表单上添加多个带日期的行

在php表单上添加多个带日期的行,php,datepicker,Php,Datepicker,这件事我已经坚持了差不多一个星期了 我一直试图在不重新加载页面的情况下将多行添加到表单的某个部分, 我克隆了字段并将它们放入数组中,但问题是日期,它不能放入数组中。。。如果有人能帮我,我将不胜感激。。。谢谢 这是我的密码: index.php <DIV id="mainContent_pnlEmploymentHistory"> <form id="form1" name="form1" method="post" action="value.php"> <TABL

这件事我已经坚持了差不多一个星期了

我一直试图在不重新加载页面的情况下将多行添加到表单的某个部分, 我克隆了字段并将它们放入数组中,但问题是日期,它不能放入数组中。。。如果有人能帮我,我将不胜感激。。。谢谢

这是我的密码:

index.php

<DIV id="mainContent_pnlEmploymentHistory">
<form id="form1" name="form1" method="post" action="value.php">
<TABLE id="dataTable">
  <TBODY>
  <TR>
    <TD style="width: 310px; height: 20px; text-align: center;">Name of Employer</TD>
    <TD style="width: 430px; height: 20px; text-align: center;"> Employer Address</TD>
    <TD style="width: 150px; height: 20px; text-align: center;">FROM</TD>
    <TD style="width: 150px; height: 20px; text-align: center;">TO</TD></TR>
  <TR class="row_to_clone_fw_emp">
    <TD style="width: 310px; height: 20px; text-align: center;"><label>
      <input type="text" id="fwemployer" name="fwemployer[]" style="width:300px"/>
    </label></TD>
    <TD style="width: 430px; height: 20px; text-align: center;">
    <input type="text" id="fwempaddress" name="fwempaddress[]" style="width:100%"/></TD>
    <TD style="width: 150px; height: 20px; text-align: center;">
<?php 
      include('calendar/classes/tc_calendar.php');
      $date3_default = "2013-10-14";
      $date4_default = "2013-10-20";
      $myCalendar = new tc_calendar("datefrom", true, false);
      $myCalendar->setIcon("calendar/images/iconCalendar.gif");
      $myCalendar->setDate(date('d', strtotime($date3_default))
            , date('m', strtotime($date3_default))
            , date('Y', strtotime($date3_default)));
      $myCalendar->setPath("calendar/");
      $myCalendar->setYearInterval(1970, 2020);
      $myCalendar->setAlignment('left', 'bottom');
      $myCalendar->setDatePair('datefrom', 'dateto', $date4_default);
      $myCalendar->writeScript();         
?>        

    </TD>
    <TD style="width: 150px; height: 20px; text-align: center;"> 
         <?php
            $date3_default = "2013-10-14";
            $date4_default = "2013-10-20";
            $myCalendar = new tc_calendar("dateto", true, false);
        $myCalendar->setIcon("calendar/images/iconCalendar.gif");
        $myCalendar->setDate(date('d', strtotime($date4_default))
              , date('m', strtotime($date4_default))
              , date('Y', strtotime($date4_default)));
        $myCalendar->setPath("calendar/");
        $myCalendar->setYearInterval(1970, 2020);
        $myCalendar->setAlignment('left', 'bottom');
        $myCalendar->setDatePair('datefrom', 'dateto', $date3_default);
        $myCalendar->writeScript();  

         ?>

    </TD>
  </TR>
  </TBODY>
</TABLE>
<input type="submit" name="Submit" value="Submit" />
</form>
<INPUT type="button" value="Add Row" onclick="addRowfwemp(); return false;"/>
</DIV>

雇主名称
雇主地址
从…起
到
名为onclick的函数如下所示:

function addRowfwemp() {
    /* Declare variables */
    var elements, templateRow, rowCount, row, className, newRow, element;
    var i, s, t;

    /* Get and count all "tr" elements with class="row".    The last one will
     * be serve as a template. */
    if (!document.getElementsByTagName)
        return false; /* DOM not supported */
    elements = document.getElementsByTagName("tr");
    templateRow = null;
    rowCount = 0;
    for (i = 0; i < elements.length; i++) {
        row = elements.item(i);

        /* Get the "class" attribute of the row. */
        className = null;
        if (row.getAttribute)
            className = row.getAttribute('class')
        if (className == null && row.attributes) {    // MSIE 5
            /* getAttribute('class') always returns null on MSIE 5, and
             * row.attributes doesn't work on Firefox 1.0.    Go figure. */
            className = row.attributes['class'];
            if (className && typeof(className) == 'object' && className.value) {
                // MSIE 6
                className = className.value;
            }
        } 

        /* This is not one of the rows we're looking for.    Move along. */
        if (className != "row_to_clone_fw_emp")
            continue;

        /* This *is* a row we're looking for. */
        templateRow = row;
        rowCount++;
    }
    if (templateRow == null)
        return false; /* Couldn't find a template row. */

    /* Make a copy of the template row */
    newRow = templateRow.cloneNode(true);

    /* Change the form variables e.g. price[x] -> price[rowCount] */
    elements = newRow.getElementsByTagName("input");
    for (i = 0; i < elements.length; i++) {
        element = elements.item(i);
        s = null;
        s = element.getAttribute("name");
        if (s == null)
            continue;
        t = s.split("[");
        if (t.length < 2)
            continue;
        s = t[0] + "[" + rowCount.toString() + "]";
        element.setAttribute("name", s);
        element.value = "";
    }

    /* Add the newly-created row to the table */
    templateRow.parentNode.appendChild(newRow);
    return true;
}
函数addRowfwemp(){
/*声明变量*/
var元素、templateRow、rowCount、row、className、newRow、element;
变量i,s,t;
/*使用class=“row”获取并计算所有“tr”元素。最后一个元素将
*作为模板*/
如果(!document.getElementsByTagName)
返回false;/*不支持DOM*/
元素=document.getElementsByTagName(“tr”);
templateRow=null;
行数=0;
对于(i=0;iprice[rowCount]*/
elements=newRow.getElementsByTagName(“输入”);
对于(i=0;i
我在脚本中使用此日期选择器: 我在下面的链接中使用“日期对示例”。


非常感谢您…

您应该保留HTML小写,以便在所有doctype上重复使用。它会给您带来什么错误?没有错误,只是如果我单击“添加行”并在第二行选择“日期”,更改将反映在第一行上……我在数组中有上述代码,但id=“datepicker-example7-start”和id=“datepicker-example7-end”未加载到第二行