Skip to content Skip to sidebar Skip to footer

Codeigniter: Table List Using Javascript And Php

table list My mind is is boggling for this logic.When I click the ADD SECTION button, a modal opens asking for input values. What I want is that, all the values from that modal wil

Solution 1:

If I understood correctly, you want to create multiple rows and then submit them as a form. Use jQuery to append table rows and to create cells containing input fields. You can set those input field names as an array <input type="text" name="section[]" value="somevaluefrommodal">

Basic html layount should look something like this:

$(document).ready(function(){
  // click handler
  $("#add-row").on("click", function() {
    $("table").append('<tr><td><input type="text" name="section[]" value="Section2"/></td><td><input type="text" name="test[]" value="Test2"/></td></tr>');
  })
})
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><buttonid="add-row">Add Row</button><form><tablestyle="width:100%"><tr><th>Section</th><th>Test</th></tr><tr><td><inputtype="text"name="section[]"value="Section1"/></td><td><inputtype="text"name="test[]"value="Test1"/></td></tr><tr><td><inputtype="text"name="section[]"value="Section2"/></td><td><inputtype="text"name="test[]"value="Test2"/></td></tr></table><inputtype="submit" /></form>

Post a Comment for "Codeigniter: Table List Using Javascript And Php"