Jump to content

Recommended Posts

While adding line items in invoice, i am trying to give product description in ckeditor editable form. But the editor is showing only for 1st product.

 

Here is the code

<table class="table table-bordered"> 
<tr>
<th><input class='check_all' type='checkbox' onclick="select_all()"/></th> 
<th>Name</th>
<th>Description</th>
<!-- Other heading like qty,tax...etc -->
</tr> 
<tr>
<td><input type='checkbox' class='case'/></td> 
<td><input type="text" class="form-control" id="productname_1" name="productname[]" style="width:120px;"></td> 
<td><textarea class="editor form-control" id="description_1" name="description[]"></textarea></td>
<!---other input values -->
<td><button type="button" class='btn btn-danger delete'>-</button></td>
<td><button type="button" class='btn btn-success addmore'>+ </button></td>
</tr></table>

Through jquery i add as many as products . my add.js goes like this

$(".delete").on('click', function() {
$('.case:checkbox:checked').parents("tr").remove();
$('.check_all').prop("checked", false);
check();
});
var i = $('table tr').length - 1;


$(".addmore").on('click', function() {
count = $('table tr').length - 1;
var data = "<tr><td><input type='checkbox' class='case'/></td><td><input class='form-control' type='text' style='width:120px;' id='productname_" + i + "' name='productname[]'/></td><td><textarea class='editor form-control' id='description_"+ i + "' name='description[]' ></textarea></td></tr>";

I add editor like this within <head> </head>

<script src="../assets/ckeditor/ckeditor.js" type="text/javascript"></script> 
<script type="text/javascript" src="../assets/ckeditor/adapters/jquery.js"></script> 
<script type="text/javascript">
$(function(){
$('.editor').ckeditor(); 
}); 
</script>

 

You already have code that inserts the data stuff into the page, right? What is it?

 

Also, your ID generation does not support when the user deletes a row from the middle of the table and then adds a new one.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.