2016-10-19 5 views
-1

データベースに動的な値を挿入したいが挿入できません。動的に追加された行の値をデータベースに挿入します

$(document).ready(function() { 
 
    
 
    $(".addCF").click(function() { 
 
    
 
    for (var i = 0; i < $("#customFieldValue").val(); i++) {} 
 
    
 
    $("#customFields").append('<tr valign="top"><th scope="row"><label for="customFieldName">Custom Field</label></th> <td><input type="text" class="code" id="customFieldValue" name="customFieldValue[]" value="" placeholder="Input Value" /> &nbsp; <a href="javascript:void(0);" class="remCF">Remove</a></td></tr>'); 
 

 
    }); 
 
    
 
    /* 
 
    for (var i = 0; i < $("#customFieldValue").val(); i++) { 
 
    } 
 
    */ 
 
    
 
    $("#customFields").on('click', '.remCF', function() { 
 
    $(this).parent().parent().remove(); 
 
    }); 
 
    
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<table class="form-table" id="customFields"> 
 
    <tr valign="top"> 
 
    <th scope="row"> 
 
     <label for="customFieldName">Custom Field 
 
     </label> 
 
    </th> 
 
    <td> 
 
     &nbsp; 
 
     <input type="text" class="code" id="customFieldValue" name="txtSubjectName[]" value="" placeholder="Input Value" />&nbsp; <a href="javascript:void(0);" class="addCF">Add</a> 
 
    </td> 
 
    </tr> 
 
</table>

答えて

0

Webページからデータベースにデータを送信するには、フォームを通してそれを送信したり、AJAXを使用するかがあります。私はあなたのコードでそれを見つけることができませんでした。

関連する問題