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

时间:2014-04-22 13:05:24

标签: 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 += 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>

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

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

            <!--------------------------------- 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>

但我需要将dynfields[]置于特定列(如numpro)和dynfieldstest[]下另一列下。

当我尝试移动它时,我dynfields[]

error : : Undefined index: dynfields in C:\wamp\www\testing\insert.php on line 285

如果我错过了一些代码,请问我,因为我只显示问题在哪里

0 个答案:

没有答案