/    Sign up×
Community /Pin to ProfileBookmark

Totals of table not getting updated when next page is clicked

Hi all,

I have a datatable built using JSF. Maximum number of rows the datatable can display is 5 and we have a datascroller to click next page.

My requirement is when I update the cell value the totals in the footer needs to be updated and I wrote JavaScript to do this and everything is working fine but when I click next the totals value is lost. My question is do I need to update this value to backing bean when I click next page??

Please look at my JavaScript code below and please give me any suggestions.

function total(){
var tr= document.getElementById(‘codForm:codData’).getElementsByTagName(‘tbody’)[0].getElementsByTagName(‘tr’);
alert(“tr length”+tr.length);
var total1=total2=total3=total4=0;

for(var i=0; i<tr.length; i++) {
var td=tr[i].getElementsByTagName(‘td’);
total1+=parseFloat(td[1].firstChild.value);
total2+=parseFloat(td[2].firstChild.value);
total3+=parseFloat(td[3].firstChild.value);
total4+=parseFloat(td[4].firstChild.value);
}

var el=document.getElementById(‘col1Footer’);
el.firstChild.data=total1;

var el1=document.getElementById(‘col2Footer’);
el1.firstChild.data=total2;

var el2=document.getElementById(‘col3Foter’);
el2.firstChild.data=total3;

var el3=document.getElementById(col4Footer’);
el3.firstChild.data=total4;

}

And my data table code in my jsp is:

<t:dataTable id=”codData” styleClass=”resultTable”
var=”codRecord” value=”#{tempBean.myList}” preserveDataModel=”false” rows=”5″ rowIndexVar=”rowIndex” frame=”border”>

please suggest.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @niki007 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...