PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Jan 21, 2017 12:33 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Sep 05, 2016 9:49 am 
Offline
Forum Commoner

Joined: Sun Jun 26, 2011 9:56 pm
Posts: 74
Quote:
for(int i=0; i<=6, i++){
<tr>
<td><span class="amtxt" >
<input type="text" name=amacount></span>
</td>
<td class="w6"><select id="level" class="sum" name="level" size="1">
<option value="">-- Please select --</option>
<option value="K1">K1</option>
<option value="K2">K2</option>
<option value="K3">K3</option>

</select></td>
</tr>
}


I want six rows, I want to get the sum for all sumK1, sumK2 ,sumK3
so far I have, but did not get what I want

Syntax: [ Download ] [ Hide ]
$(".sum").each(function() {

                                if ($(this).children().val() == "K1") {
                                        alert(am_value + $(this).children().val());
                               
                                        sumk1+=(!isNaN(am_value) && $.isNumeric(am_value)) ? parseInt(am_value) : 0;
                               
                                }      

                        });


Top
 Profile  
 
PostPosted: Mon Sep 05, 2016 8:13 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6332
Location: WA, USA
"K1" isn't a number. You can't sum those...

Syntax: [ Download ] [ Hide ]
$(this).children().val()

That will get the value of the first child. You need just $(this).val() for the value of the select.

And if you haven't already, sumk1 has to be defined before and outside the each().


Top
 Profile  
 
PostPosted: Mon Sep 05, 2016 8:41 pm 
Offline
Forum Commoner

Joined: Sun Jun 26, 2011 9:56 pm
Posts: 74
i have two column i did not sum K1 , I sum every number relate to K1 and I have the sum define outside each


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group