<div class="container" id="assignPackage">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Group Name</th>
<th style="text-align: center" valign="middle">Minmum Transaction Limit</th>
<th style="text-align: center" valign="middle">Maximum Transaction Limit</th>
<th style="text-align: center" valign="middle">Day Transaction Limit</th>
<th style="text-align: center" valign="middle">No. of Transaction Per Day</th>
</tr>
</thead>
<tbody data-bind="foreach: records">
<tr>
<td data-bind="text:packageName"></td>
<td> <div contenteditable></div> </td>
<td> <div contenteditable></div> </td>
<td> <div contenteditable></div> </td>
<td> <div contenteditable></div> </td>
</tr>
</tbody>
</table>
<br><br>
<button data-bind="click :$root.create" class="btn btn-success">Create Group</button>
<a href="<?php echo base_url(); ?>transaction_limit_setup" class="btn btn-success"><i class="icon-plus icon-white"></i><span>Cancel</span></a>
</div>
Here is My html table in which the column Group Name is created with data binding and the rest of the columns are editable i.e. user will put values there. Now when I click button "Create Group" it will call a Js function named create.
<script type="text/javascript" charset="utf-8">
var initialData = jQuery.parseJSON('<?= $packages ?>');//data for building initial table
var vm = function() {
var self = this;
self.records = ko.observableArray(initialData);
$.each(self.records(), function(i, record){
record.packageName = record.packageName;
})
self.create = function()
{
}
}
ko.applyBindings(new vm());
</script>
and inside the function I want to initiate an Ajax post to a PHP function with all the values from the table i.e. the values from column "Group name" and also the other columns which the user will give input.
How can I do that.