I have inserted a table template into a free text field using JEditor. Users will enter numbers across each row. Is there a way to total the numbers in the last column?
Thank you for your suggestion. I tries it out and it did not work exactly the way that I needed it to work. I have found an alternative solution. Thank you again.
Hi Cindy,
Thank you for your interest in JEditor.
This is possible with JEditor 1.5.45. You need to add some javascript in JEditor Configuration > Custom Javascript.
I'll provide a simple example of this function. Create new template using sample html code and add sample javascript code to custom javascript in JEditor Configuration.
You can use this sample as basis for your solution. Please feel free to contact our support if you need any help with developing your macro.
Sample HTML code
<table border="1" cellpadding="1" cellspacing="1" class="sum" style="width: 500px; border-collapse: collapse; ">
<thead>
<tr>
<th>
Value 1</th>
<th>
Value 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>
15432</td>
<td>
4324</td>
</tr>
<tr>
<td>
42343</td>
<td>
234324</td>
</tr>
<tr>
<td>
123</td>
<td>
2343</td>
</tr>
</tbody>
</table>
Sample javascript code
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function ()
{
AJS.$('table.sum tbody tr').each(function() {
var numbers = AJS.$('td:not(".total")', this),
total = 0;
numbers.each(function() {
total+= parseInt( AJS.$(this).text(), 10);
});
if (AJS.$(this).find('td.total').length == 0) AJS.$(this).append('<td class="total"><b>'+total+'</b></td>');
});
});
AJS.$(function(){
AJS.$('table.sum tbody tr').each(function() {
var numbers = AJS.$('td:not(".total")', this),
total = 0;
numbers.each(function() {
total+= parseInt( AJS.$(this).text(), 10);
});
if (AJS.$(this).find('td.total').length == 0) AJS.$(this).append('<td class="total"><b>'+total+'</b></td>');
});
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.