Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/465.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
Javascript 在动态行的后面插入_Javascript_Php_Html_Dynamic_Row - Fatal编程技术网

Javascript 在动态行的后面插入

Javascript 在动态行的后面插入,javascript,php,html,dynamic,row,Javascript,Php,Html,Dynamic,Row,我有一个动态添加行按钮。我可以添加更多ID和更多客户端,但当我单击plus时,它会将它们添加到页面顶部,而不是我的行之后。我该怎么做?这是我的密码: <b>Dimanche</b> </br><?php echo $date1 ?> </td> <!-- numéro de projet du dimanche --> <td> <s

我有一个动态添加行按钮。我可以添加更多ID和更多客户端,但当我单击
plus
时,它会将它们添加到页面顶部,而不是我的行之后。我该怎么做?这是我的密码:

    <b>Dimanche</b> </br><?php echo $date1 ?>
        </td>
        <!-- numéro de projet du dimanche -->
        <td>
         <span id="numpro" >
            <form method="post" action="" onsubmit="return false;">
                   <input type="text" id="name" name="add_name"onkeypress="return handleEnter(event, this, 'task');"/></br>
      <?php
    if($result!=false && mysqli_num_rows($result)>0)
    {
        while($product = mysqli_fetch_array($result)): ?>
           <p id="oldRow<?=$product['id']?>">
            <input type="text" name="name<?=$product['id']?>" value="<?=$product['name']?>" /></p>
     <?php endwhile; } ?>
        </span> 
         <input onclick="addRow(this.form);" type="button" value="+" /> 
        </td>
        </form>


        <html>
          <div >
            <form method="post"  >
          <div id="itemRows">

     <?php
    if($result!=false && mysqli_num_rows($result)>0)
    {
        while($product = mysqli_fetch_array($result)): ?>

            <p id="oldRow<?=$product['id']?>">
            <input type="text" name="name<?=$product['id']?>" value="<?=$product['name']?>" /></p>
 <?php endwhile;   }  ?>
     </div>
        <p><input type="submit" name="ok" value="Ajouter à la B.D"></p>
        </form>
    </div>

    <script type="text/javascript">
    var rowNum = 0;
    function addRow(frm) {
        rowNum ++;

        var row = '<p id="rowNum'+rowNum+'">  <input type="text" name="name[]" value="'+frm.add_name.value+'">    <input type="text" name="client1[]" size="12"  class = "client1"  id ="client1" disabled  value="'+frm.client1.value+'"><input type="button" value="-" onclick="removeRow('+rowNum+');"></p>';
        jQuery('#itemRows').append(row);
        frm.add_client1.value = '';
        frm.add_name.value = '';
    }

    function removeRow(rnum) {
        jQuery('#rowNum'+rnum).remove();
    }
    </script>



                    </span> 

                </td>
                </td>
                <!-- client du dimanche -->
                <td>
                    <span id="proclient">

                <input type="text" name="client1" size="12" class = "client1"  id ="client1" disabled />
                    </span>
                </td>
                <!-- description du projet de dimanche -->
                <td>
                    <span id="prodesc">
                        <input type="text" name="desc1" size="30" id ="desc1" class "desc" disabled />
                    </span>
                </td>
                <!-- ddescription de la tache du dimanche -->
                <td>
                    <span id="protache">
                        <textarea rows="1" cols="20" name="taskDesc1" id ="task1" class "task"> </textarea>
                    </span>
                </td>
                <!-- lieu pour dimanche -->
                <td>
                    <span id="prolieu">
                        <input type="text" name="prolieu1" size="10" id ="lieu1" class "lieu">
                    </span> 
                </td>   


                <!-- tache  -->     
                <td>
                    <span id="tache">
                    <!--    <input type="text"  name="tache" size="30" id="tache"class= "tache"  />  -->    

    <!-- début section cobobox tache avec tool tip -->                  
                        <label title="Select your state"> <select title="Select your state" id="state" name="state">
                        <?php

                            $stmt->execute();
                            while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                                echo ' <option title="';
                                echo $row['tacName'];
                                echo '">';
                                echo $row['tacId'];
                                echo '</option>'."\n";
                             $task = array();

                                //echo '<option value="'.$row['tacName'].'">'.$row['tacId'].'</option>'."\n";
                            }
                        ?>
    </select>
    </label>
    <!-- Fin section cobobox tache avec tool tip -->        


                    </span>
                </td>


                <!-- calculter le temps pour le diamnche -->        
                <td>
                    <span id="calculTemps">
                        <input type="number"  name="tempsd" size="30" id="temps1"class= "temps"   min= "0" max="24" value="0"  />   

                    </span>
                </td>
Dimanche

在这里编辑我的问题演示

在这里编辑我想要的目标演示

尝试使用JQuery函数和选择器:last:first

常见示例:
jQuery(“”).html('Some content').insertAfter('id#u here:last')

jQuery(“”).html(“某些内容”).appendTo(“#itemRows”)

你想在这里编写什么代码???当我添加一行时,他们会将其添加到我的页面顶部,我需要在我的行后添加它。添加名称标签如何出现在页面中间?可能是一个错误,我忘了删除它。你能分享一些屏幕截图或演示吗。因为jQuery('#itemRows').append(row);我觉得很好..不工作吗?我需要输入哪个ID以确保我没有出错?