Solved

accumulation of totals working - cannnot "get to" footer to show subtotals!

Posted on 2013-02-04
10
302 Views
Last Modified: 2013-02-04
The alert message boxes show the correct totals:

  $('span').filter(function() { return ( $(this).attr("id").indexOf("lblAmt")>=0 ) && ( $(this).attr("id").indexOf("gvRepair")>=0 ); }).each(function () {
            subtotRepair += parseFloat($(this).text());
        });

        $('span').filter(function () { return ($(this).attr("id").indexOf("lblAmt") >= 0) && ($(this).attr("id").indexOf("gvRecommended") >= 0); }).each(function () {
            subtotRecommended += parseFloat($(this).text());
        });


        alert(subtotRepair);
        alert(subtotRecommended);

Open in new window




but then I am trying to set the text for the subtotals:

     //   $('.grid_view_footer tr:nth-child(1)').text(tot);


and it is not working:


Here is the rendered HTML.   I will indicate IN ALL CAPS where the subtotals should go.

It looks like in each case the sub totals are at the BOTTOM of the grid view markup:


for grid view "gvRepair":
<table class="grid_view" cellspacing="0" id="ctl09_gvRepair" style="border-collapse: collapse; position: relative; left: 75px;">
			<tbody><tr class="grid_view_header">
				<th scope="col">Repair Item</th><th scope="col" style="text-align: left;">Details</th><th scope="col">Include</th><th scope="col">Bid 1 Qty</th><th scope="col">Bid 1 Amt</th><th scope="col">&nbsp;</th>
			</tr><tr id="ctl09_gvRepair_ctl02" onclick="HighLightGVRow('ctl09_gvRepair_ctl02', 'ctl09_gvRepair_ctl02_hdSelectedRow', 'ctl09_gvRepair_ctl02_hdOldStyle');">
				<td style="width:100px;">                                
                                <span id="ctl09_gvRepair_ctl02_lblItems" style="display:inline-block;width:150px;">Electrical</span>
                            </td><td>
                                

<table style="margin: 0; padding: 0; ">
    <tbody><tr style="margin: 0; padding: 0;">
        <td style="margin: 0; padding: 0; float: right;"><span id="ctl09_gvRepair_ctl02_iconDetails_lblMessage" style="display:block;padding:0;overflow:hidden;width:0px;height:;">request marketing plan repair bids - details for category electrical, repair item "replace light fixtures" asset id 32122, assettaskid 2760335, menu id 211</span></td>
        <td style="margin: 0; padding: 0;">
            <div id="ctl09_gvRepair_ctl02_iconDetails_divMessage" style="display: block; width: 17px; height: 18px; " title="" bt-xtitle="request marketing plan repair bids - details for category electrical, repair item &quot;replace light fixtures&quot; asset id 32122, assettaskid 2760335, menu id 211">
                <img id="ctl09_gvRepair_ctl02_iconDetails_imgPopup" onload="scrollDetect('ctl09_gvRepair_ctl02_iconDetails_imgPopup', 'ctl09_gvRepair_ctl02_iconDetails_lblMessage');" src="Images/dot_dot_dot.gif" style="">
            </div>
        </td>
    </tr>
</tbody></table>





                            </td><td style="width:50px;">
                                <span class="aspNetDisabled"><input id="ctl09_gvRepair_ctl02_chkActive" type="checkbox" name="ctl09$gvRepair$ctl02$chkActive" checked="checked" disabled="disabled"></span>
                            </td><td>
                                 <span id="ctl09_gvRepair_ctl02_lblQty1">5</span>
                                <span id="ctl09_gvRepair_ctl02_lblUnitDesc1"></span>
                            </td><td style="width:100px;">
                                <span id="ctl09_gvRepair_ctl02_lblAmt1">700.00</span>
                            </td><td>
                                
                            </td><td><input type="hidden" name="ctl09$gvRepair$ctl02$hdSelectedRow" id="ctl09_gvRepair_ctl02_hdSelectedRow"><input type="hidden" name="ctl09$gvRepair$ctl02$hdOldStyle" id="ctl09_gvRepair_ctl02_hdOldStyle"></td>
			</tr><tr id="ctl09_gvRepair_ctl03" class="grid_view_alt_row" onclick="HighLightGVRow('ctl09_gvRepair_ctl03', 'ctl09_gvRepair_ctl02_hdSelectedRow', 'ctl09_gvRepair_ctl02_hdOldStyle');">
				<td style="width:100px;">                                
                                <span id="ctl09_gvRepair_ctl03_lblItems" style="display:inline-block;width:150px;">Plumbing</span>
                            </td><td>
                                

<table style="margin: 0; padding: 0; ">
    <tbody><tr style="margin: 0; padding: 0;">
        <td style="margin: 0; padding: 0; float: right;"><span id="ctl09_gvRepair_ctl03_iconDetails_lblMessage" style="display:block;padding:0;overflow:hidden;width:0px;height:;">request marketing plan repair bids - details for category plumbing, repair item "install replace sump pump" asset id 32122, assettaskid 2760335, menu id 211</span></td>
        <td style="margin: 0; padding: 0;">
            <div id="ctl09_gvRepair_ctl03_iconDetails_divMessage" style="display: block; width: 17px; height: 18px; " title="" bt-xtitle="request marketing plan repair bids - details for category plumbing, repair item &quot;install replace sump pump&quot; asset id 32122, assettaskid 2760335, menu id 211">
                <img id="ctl09_gvRepair_ctl03_iconDetails_imgPopup" onload="scrollDetect('ctl09_gvRepair_ctl03_iconDetails_imgPopup', 'ctl09_gvRepair_ctl03_iconDetails_lblMessage');" src="Images/dot_dot_dot.gif" style="">
            </div>
        </td>
    </tr>
</tbody></table>





                            </td><td style="width:50px;">
                                <span class="aspNetDisabled"><input id="ctl09_gvRepair_ctl03_chkActive" type="checkbox" name="ctl09$gvRepair$ctl03$chkActive" checked="checked" disabled="disabled"></span>
                            </td><td>
                                 <span id="ctl09_gvRepair_ctl03_lblQty1">1</span>
                                <span id="ctl09_gvRepair_ctl03_lblUnitDesc1"></span>
                            </td><td style="width:100px;">
                                <span id="ctl09_gvRepair_ctl03_lblAmt1">1700.00</span>
                            </td><td>
                                
                            </td>
			</tr><tr class="grid_view_footer">
				<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>Subtotals:</td><td>SUB TOTAL FOR GVREPAIR SHOULD GO HERE</td><td>&nbsp;</td>
			</tr>
		</tbody></table>

Open in new window






for grid view "gvRecommended":
<table class="grid_view" cellspacing="0" id="ctl09_gvRecommended" style="border-collapse: collapse; position: relative; left: 75px;">
			<tbody><tr class="grid_view_header">
				<th scope="col">Repair Item</th><th scope="col" style="text-align: left;">Details</th><th scope="col">Include</th><th scope="col">Bid 1 Qty</th><th scope="col">Bid 1 Amt</th><th scope="col">&nbsp;</th>
			</tr><tr id="ctl09_gvRecommended_ctl02" onclick="HighLightGVRow('ctl09_gvRecommended_ctl02', 'ctl09_gvRecommended_ctl02_hdSelectedRow', 'ctl09_gvRecommended_ctl02_hdOldStyle');">
				<td style="width:100px;">                                
                                <span id="ctl09_gvRecommended_ctl02_lblItems" style="display:inline-block;width:150px;">Electrical</span>
                            </td><td>
                                

<table style="margin: 0; padding: 0; ">
    <tbody><tr style="margin: 0; padding: 0;">
        <td style="margin: 0; padding: 0; float: right;"><span id="ctl09_gvRecommended_ctl02_iconDetails_lblMessage" style="display:block;padding:0;overflow:hidden;width:0px;height:;">other rec repairs</span></td>
        <td style="margin: 0; padding: 0;">
            <div id="ctl09_gvRecommended_ctl02_iconDetails_divMessage" style="display: block; width: 17px; height: 18px; " title="" bt-xtitle="other rec repairs">
                <img id="ctl09_gvRecommended_ctl02_iconDetails_imgPopup" onload="scrollDetect('ctl09_gvRecommended_ctl02_iconDetails_imgPopup', 'ctl09_gvRecommended_ctl02_iconDetails_lblMessage');" src="Images/dot_dot_dot.gif" style="">
            </div>
        </td>
    </tr>
</tbody></table>





                            </td><td style="width:50px;">
                                <span class="aspNetDisabled"><input id="ctl09_gvRecommended_ctl02_chkActive" type="checkbox" name="ctl09$gvRecommended$ctl02$chkActive" checked="checked" disabled="disabled"></span>
                            </td><td>
                                 <span id="ctl09_gvRecommended_ctl02_lblQty1">20</span>
                                <span id="ctl09_gvRecommended_ctl02_lblUnitDesc1"></span>
                            </td><td style="width:100px;">
                                <span id="ctl09_gvRecommended_ctl02_lblAmt1">1200.13</span>
                            </td><td>
                                
                            </td><td><input type="hidden" name="ctl09$gvRecommended$ctl02$hdSelectedRow" id="ctl09_gvRecommended_ctl02_hdSelectedRow"><input type="hidden" name="ctl09$gvRecommended$ctl02$hdOldStyle" id="ctl09_gvRecommended_ctl02_hdOldStyle"></td>
			</tr><tr id="ctl09_gvRecommended_ctl03" class="grid_view_alt_row" onclick="HighLightGVRow('ctl09_gvRecommended_ctl03', 'ctl09_gvRecommended_ctl02_hdSelectedRow', 'ctl09_gvRecommended_ctl02_hdOldStyle');">
				<td style="width:100px;">                                
                                <span id="ctl09_gvRecommended_ctl03_lblItems" style="display:inline-block;width:150px;">HVAC</span>
                            </td><td>
                                

<table style="margin: 0; padding: 0; ">
    <tbody><tr style="margin: 0; padding: 0;">
        <td style="margin: 0; padding: 0; float: right;"><span id="ctl09_gvRecommended_ctl03_iconDetails_lblMessage" style="display:block;padding:0;overflow:hidden;width:0px;height:;">rep serv condenser</span></td>
        <td style="margin: 0; padding: 0;">
            <div id="ctl09_gvRecommended_ctl03_iconDetails_divMessage" style="display: block; width: 17px; height: 18px; " title="" bt-xtitle="rep serv condenser">
                <img id="ctl09_gvRecommended_ctl03_iconDetails_imgPopup" onload="scrollDetect('ctl09_gvRecommended_ctl03_iconDetails_imgPopup', 'ctl09_gvRecommended_ctl03_iconDetails_lblMessage');" src="Images/dot_dot_dot.gif" style="">
            </div>
        </td>
    </tr>
</tbody></table>





                            </td><td style="width:50px;">
                                <span class="aspNetDisabled"><input id="ctl09_gvRecommended_ctl03_chkActive" type="checkbox" name="ctl09$gvRecommended$ctl03$chkActive" checked="checked" disabled="disabled"></span>
                            </td><td>
                                 <span id="ctl09_gvRecommended_ctl03_lblQty1">1</span>
                                <span id="ctl09_gvRecommended_ctl03_lblUnitDesc1"></span>
                            </td><td style="width:100px;">
                                <span id="ctl09_gvRecommended_ctl03_lblAmt1">1333.33</span>
                            </td><td>
                                
                            </td>
			</tr><tr class="grid_view_footer">
				<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>Subtotals:</td><td>SUB TOTAL FOR GVRECOMMENDED SHOULD GO HERE</td><td>&nbsp;</td>
			</tr>
		</tbody></table>

Open in new window

0
Comment
Question by:Tom Knowlton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 38853346
Use : $('.grid_view_footer td:eq(4)').text(tot)
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38853353
That works, but only on the FIRST grid view (table) for "gvRepair"


It did not do the same thing for "gvRecommended".
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38853356
How do I say:

   $('.grid_view_footer td:eq(4)').text(subtotRepair);   for "gvRepair"


and then

   $('.grid_view_footer td:eq(4)').text(subtotRecommended);   for "gvRecommended"
0
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
LVL 82

Expert Comment

by:leakim971
ID: 38853359
$('.grid_view_footer td:eq(4)', "#ctl09_gvRepair").text(subtotRepair);

 $('.grid_view_footer td:eq(4)', "#ctl09_gvRecommended").text(subtotRepair);

or :

 $("#ctl09_gvRepair").find('.grid_view_footer td:eq(4)').text(subtotRepair);

 $("#ctl09_gvRecommended").find('.grid_view_footer td:eq(4)').text(subtotRepair);
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38853364
In case it is not ctl09 each time, can I do a "*= gvRepair" or something?


Please show me what that code would look like.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 38853369
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38853374
I'd rather just search for the existence of "gvRepair" in the ID name at this point.


Can you paste an example of that approach?
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38853381
I think maybe I got it:

        
        $('.grid_view_footer td:eq(4)', '[id*="gvRepair"]').text(subtotRepair);


        $('.grid_view_footer td:eq(4)', '[id*="gvRecommended"]').text(subtotRecommended); 

Open in new window

0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 38853384
While I have you here - is there a way to format the subtotals with more of a "currency" look and feel?

Instead of:

2400

I'd like to display

$2400.00
0
 
LVL 82

Expert Comment

by:leakim971
ID: 38853439
text(  "$" + tot.toFixed(2)   )
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question