Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.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_Dynamic_Append_Row - Fatal编程技术网

Javascript 在适当的字段中添加动态行

Javascript 在适当的字段中添加动态行,javascript,php,dynamic,append,row,Javascript,Php,Dynamic,Append,Row,您好,我在将字段添加到正确的行下时遇到了一个小问题 当我这样做的时候: <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> var counter = 0; $(function() { $('p#add_field').click(function() { counter +=

您好,我在将字段添加到正确的行下时遇到了一个小问题

当我这样做的时候:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
    var counter = 0;
    $(function() {
        $('p#add_field').click(function() {
            counter += 1;
            $('#container').append(
                    '<input id="field_' + counter + '" name="dynfields[]' + '" type="text" />'
                    +
                    '<input id="field_' + counter + '" name="dynfieldstest[]' + '" type="text" /><br />'
//+   ' <button onClick="$(this).parent('div').remove()">remove</button>'
                    )
        });
    });
///
</script> 
<body>
    <?php if (!isset($_POST['submit_val'])) { ?>
    <form method="post" action="insert.php">
    </td>   
    <!-- num곯 de projet du dimanche -->
    <td>
        <span id="numpro" >
            <div id="container"> 
                <p id="add_field"><a href="#"><span>add</span>   </a></p>
                <input onblur="autre();" onfocus="enter();" type="text" id="projdim" name="projdim"onkeypress="return handleEnter(event, this, 'task');"/>  
            </div>
        </span>

var计数器=0;
$(函数(){
$('p#添加_字段')。单击(函数(){
计数器+=1;
$(“#容器”)。追加(
''
+
“
” //+“删除” ) }); }); ///

它不起作用,但当我做这样的事情时,它起作用了:

在这里编辑我的代码一天是的,这不是最好的代码,但我一直在尝试和实践编程

            <!--------------------------------- JOURNʅ DE DIMANCHE --------------------------->
        <tr>
            <!-- If I delete this my code crash I don't know why -->    
        <form method="post"  >
            <div id="itemRows">
            </div>
        </form>
            <td>

    <form method="post" action="insert.php">

                <b>Dimanche</b> </br><?php echo $date1 ?>




                <script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
var counter = 0;
$(function(){
    $('p#add_field').click(function(){
        counter += 1;
        $('#container').append(


                '<input id="field_' + counter + '" name="dynfields[]' + '" type="text" />'
                +
                '<input id="field_' + counter + '" name="dynfieldstest[]' + '" type="text" /><br />'
//+   ' <button onClick="$(this).parent('div').remove()">remove</button>'
                )




    });
});

///

</script> 

<body>


<?php if (!isset($_POST['submit_val'])) { ?>

    <form method="post" action="insert.php">

        <div id="container"> 

            <p id="add_field"><a href="#"><span>add</span>  </a></p>
        </div>


            </td>   
            <!-- num곯 de projet du dimanche -->
            <td>
               <span id="numpro" >

                        <input onblur="autre();" onfocus="enter();" type="text" id="projdim" name="projdim"onkeypress="return handleEnter(event, this, 'task');"/>  
                </span>         

            <!-- fonction doubler la rangꥠdu dimanche -->   

            </td>

            <!-- client du dimanche -->
            <td>
                <span id="proclient">   
                <input type="text" name="clientdim" class = "client" size="12" id ="clientdim" readonly />

                </span>
            </td>
            <!-- description du projet de dimanche -->

            <td>
                <span id="prodesc">
                    <input type="text" size="30" id ="prodescdim" class "prodescdim" readonly name="prodescdim" />
                </span>
            </td>

            <!-- ddescription de la tache du dimanche -->
            <td>
                <span id="protache">
                    <textarea rows="1" cols="20" id ="taskdim" class "taskdim"> </textarea>
                </span>
            </td>


            <!-- lieu pour dimanche -->
            <td>
                <span id="prolieu">
                    <input type="text"  size="10" id ="lieudim" class="lieudim" name="lieudim"/>
                </span> 
            </td>   

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

                <!-- dꣵt section combobox tache avec tool tip -->                   
                    <label title="Selectdimanche"> <select title="Selectdimanche" id="Selectdimanche" name="Selectdimanche">

                    <?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();
                            }
                    ?>
</select>
</label>
<!-- Fin section cobobox tache avec tool tip -->        

                </span>
            </td>



            <!-- calculter le temps pour le dimanche -->        
            <td>
                <span id="calculTemps">
                <input type="number"  id="input1"  class="temps"  name="tempsd" size="10" min="0" max="24" value="0"/><br/>

                </span>
            </td>


            </br>


        </tr>
<input type="text" id="result" readonly="readonly" name="total" />
<input type="hidden" name="date2" value="<?php echo $date; ?>" />
<input type="submit" name="submit_val"  value="Terminé" id="end" />
<input type="hidden" name="data" value="<?php echo $date; ?>" />
<input type="hidden" name="usrUserName" value="<?php echo $usrUserName; ?>" />

</p>
</form>

<?php } ?>
    </td>

迪曼奇
var计数器=0; $(函数(){ $('p#添加_字段')。单击(函数(){ 计数器+=1; $(“#容器”)。追加( '' + “
” //+“删除” ) }); }); ///




您的HTML在第一个中无效。你有
而没有匹配的
,而且
元素必须直接在
中,它们不能在
中。你需要显示更多的代码,因为你所说的PHP错误不是由这个示例生成的……你的jQuery代码正在创建重复的ID——你有两个
,我在这里编辑我的代码,但是当我在版本中添加到我的数据库时,我说它正确地工作了。@Barmar我只是更改了我输入的Id