Php “中输入字段的类型”;表格「;不适用于Jquery

Php “中输入字段的类型”;表格「;不适用于Jquery,php,jquery,html,forms,input,Php,Jquery,Html,Forms,Input,我的项目有问题。我有一个带有行的时间表,可以使用Jquery动态添加更多行 代码为: <?php session_start(); ?> <html lang="es"> <head> <meta charset="iso-8859-1"> <script type="text/javascript" src="jquery.js"></script> <script type="

我的项目有问题。我有一个带有行的时间表,可以使用Jquery动态添加更多行

代码为:

<?php

session_start();

?>

<html lang="es">
    <head>
    <meta charset="iso-8859-1">
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript" src="rows_management.js"></script>


    </head>
    <body>
    <div id="elements">
    <form id="data" action="timetable_processing.php" method="post">
    <table border="1" id="table">
    <thead>
    <tr>
    <td>Hour</td>
    <td>Monday</td>
    <td>Tuesday</td>
    <td>Wednesday</td>
    <td>Thursday</td>
    <td>Friday</td>
    </tr>
    </thead>

    <tbody>
    <tr class="first-row">
    <td><input type="time" name="hour[0]" placeholder="hour"></td>
    <td><input type="text" name="subject_mon[0]" placeholder="Subject"><br><input type="text" name="id_user_mon[0]"placeholder="Id_teacher"></td>
    <td><input type="text" name="subject_tue[0]" placeholder="Subject"><br><input type="text" name="id_user_tue[0]"placeholder="Id_teacher"></td>
   <td><input type="text" name="subject_wed[0]" placeholder="Subject"><br><input type="text" name="id_user_wed[0]"placeholder="Id_teacher"></td>
<td><input type="text" name="subject_thu[0]" placeholder="Subject"><br><input type="text" name="id_user_thu[0]"placeholder="Id_teacher"></td>
<td><input type="text" name="subject_fri[0]" placeholder="Subject"><br><input type="text" name="id_user_fri[0]"placeholder="Id_teacher"></td>
    <td class="remove">Remove</td>
    </tr>
    <input type="hidden" name="year" id="year" value="<?php echo $year ?>">
    <input type="hidden" name="class" id="class" value="<?php echo $class ?>">

    </tbody>
    </table>

    <input type="button" id="add" value="Add row" />
    <input type="submit" id="submit"  value="Submit">

    </form>
    </div>
    <?php
        $connection = mysql_connect("localhost", "alonsosjumper", "alonsosjumper") or die('It´s not possible to connect: ' . mysql_error());
echo '<br>OK, all correct<br>';

mysql_select_db("project", $connection) or die('It´s not possible to open the database');

    $query= "select id_user, name, surnames from users where user_type='teacher' order by id_user";
    $result= mysql_query($query);

    echo ' <p>Teachers:</p>
    <table border="1" width="auto">
    <tr><td>Id_user</td><td>Name</td><td>Surnames</td></tr>';

    while($row = mysql_fetch_array($result))
{

    echo "<tr><td>".$fila['id_user']."</td><td>".$fila['name']."</td><td>".$fila['surnames']."</td></tr>";
}

    ?>
    </body>
</html> 

时辰
星期一
星期二
星期三
星期四
星期五





去除
你的字符串有点不连贯,像
name='hour['+countInputs+'].
这样的部分应该是
name='hour[“+countInputs+]”
,因为你使用的是
引用您的字符串。

很可能是浏览器无法识别该字符串。jQuery只是将它传递给
。innerHTML
注意,字符串连接不起作用,引号错误(这可能是问题的真正原因)“我的怀疑是”你想要的单词是“问题”,而不是“怀疑”。你可能经常看到“怀疑”,因为它(显然)是印度次大陆的方言。但从您的姓名和HTML页面的语言来看,我猜您不在印度次大陆。:-)我之所以提到这一点,是因为尽管这不是你的第一语言,但你的英语很好。@KevinB在Internet Explorer中第一行也不起作用,但是在Chrome上,第一行起作用,但另一行不行。我将name='hour['+countInputs+']'改为name='hour[“+countInputs+”],但它不起作用。…@t.J.Crowder no,我来自西班牙西德。我认为怀疑可以用作“问题”xD谢谢你的更正:)对不起,你的答案不起作用。在Internet Explorer中,第一行也不起作用,但是在Chrome上,第一行起作用,但另一行不行。现在它起作用了!,这是一个很简单的例子。谢谢
$(document).ready(function(){
    var countInputs = ($(".first-row").length);

    $("#add").on('click', function(){
        $('#table > tbody:last').after("<tr><td><input type='time' name='hour['+countInputs+']' placeholder='Hour'></td><td><input type='text' name='subject_mon['+countInputs+']' placeholder='Subject'><br><input type='text' name='id_user_mon['+countInputs+']' placeholder='Teacher'></td><td><input type='text' name='subject_tue['+countInputs+']' placeholder='Subject'><br><input type='text' name='id_user_tue['+countInputs+']' placeholder='Teacher'></td><td><input type='text' name='subject_wed['+countInputs+']' placeholder='Subject'><br><input type='text' name='id_user_wed['+countInputs+']' placeholder='Teacher'></td><td><input type='text' name='subject_thu['+countInputs+']' placeholder='Subject'><br><input type='text' name='id_user_thu['+countInputs+']' placeholder='Teacher'></td><td><input type='text' name='subject_fri['+countInputs+']' placeholder='Subject'><br><input type='text' name='id_user_fri['+countInputs+']' placeholder='Teacher'></td><td class='remove'>Remover</td></tr>");
        countInputs++;

    });

    $(document).on("click",".remove",function(){
        if (countInputs>1)
        {
        var parent = $(this).parents().get(0);
        $(parent).remove();
        countInputs--;

        }
        else
            alert("It´s not possible to remove the last row");
    });

});
<td><input type="time" name="hour[0]" placeholder="hour"></td>
<td><input type="time" name="hour[0]" placeholder="hour"></td>