1,105,384 Community Members

Total for Dynamic Text box

Member Avatar
rpv_sen
Posting Whiz in Training
260 posts since Mar 2011
Reputation Points: 14 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 1 [?]
 
0
 

Hi Friends.

i am working on my internal work. i am having n dynamic rows, Each and every row contain total.

i want to sum all the rows total.

i have attached the screen shot for the reference

Attachments sum_textbox.jpg 8.25KB
Member Avatar
masterjiraya
Posting Whiz
327 posts since Jul 2008
Reputation Points: -3 [?]
Q&As Helped to Solve: 32 [?]
Skill Endorsements: 4 [?]
 
0
 

ican't figure it out if this textbox, label or what.

Member Avatar
paulrajj
Junior Poster
102 posts since Mar 2010
Reputation Points: 6 [?]
Q&As Helped to Solve: 38 [?]
Skill Endorsements: 0 [?]
 
0
 

Use javascript or jQuery to add every rows totalrate value and show it in a total value. Providing some code may help to fix ur problem.

Member Avatar
rpv_sen
Posting Whiz in Training
260 posts since Mar 2011
Reputation Points: 14 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 1 [?]
 
0
 

Hi

i have posted my script, i have written script for multiplication. but i need script for sum of total_rate in GrandTotal

<table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <thead>
                                      <tr>
                                        <th width="6%" height="30" align="center"><span class="tabletitle">S.No</span></th>
                                        <th width="44%"><span class="tabletitle">Description</span></th>
                                        <th width="13%"><span class="tabletitle">UOM</span></th>
                                        <th width="11%"><span class="tabletitle">Qty</span></th>
                                        <th height="30"><span class="tabletitle">Rate</span></th>
                                        <th width="16%"><span class="tabletitle">Total Rate</span></th>
                                      </tr>
                                    </thead>
                                    <tbody>
                                      <?php
									  
					$create_po1 = $_POST['create_po'];
					
					$mat_po = $_POST['material_id'];
										
					$limit2 = count($create_po1);
					$j=1;
					for($k=0;$k<$limit2;$k++)
					{
						
						$create_po1[$k] = mysql_real_escape_string($create_po1[$k]);						
						
						$c_po = $create_po1[$k];
						$mat_po1 = $mat_po[$k];
					
					$qr = "select * from material_indent_req where id='$c_po' and status='Approved'";
					//echo $qr;
				
					$qres = mysql_query($qr,$conn);
					
					while($qrow = mysql_fetch_array($qres))
					{
					
					$qindent_no = $qrow['indent_no'];
					
					$qmat = $qrow['material_subcat_code'];
					
					$qmatname = $qrow['material_subcat_name'];
					
					$qsite = "select *,count(po_no),sum(required_qty) from material_po where indent_no='$qrow[indent_no]' and material_id='$qmat'";
					//echo $qsite;
					$qrsite = mysql_query($qsite,$conn);
					$qmsite = mysql_fetch_array($qrsite);
										
					$req_ty = $qmsite['sum(required_qty)'];
					
					$site = $qrow['sitename'];
					
					$count_po = $qmsite['count(indent_no)'] + 1;
					
					$pending_qty = $qrow['required_qty'] - $req_ty;
					
					?>
				                    <tr class="light">
                                        <td height="30" align="center"><span class="logintitle"><?php echo $j;?></span></td>
                                        <td><span class="logintitle"><?php echo $qmatname;?></span></td>
                                        <td><span class="logintitle"><?php echo $qrow['unit'];?></span></td>
                                        <td><input name="required_qty[]" type="text" class="inputline" id="required_qty<?php echo $j;?>" value="<?php echo $pending_qty;?>" size="12" /></td>
                                        <td width="10%"><input name="rate[]" type="text" class="inputline" id="rate<?php echo $j; ?>" onchange="multiply(<?php echo $j; ?>)" size="12"/></td>
                                        <td><input name="total_rate[]" type="text" class="inputline" id="total_rate<?php echo $j; ?>" size="18" readonly="readonly"/></td>
                                      </tr>
                                      <?php $j++; } } ?>
                                      <tr class="dark">
                                        <td height="30" colspan="4">&nbsp;</td>
                                        <td><span class="tabletitle">Total </span></td>
                                        <td><input name="GrandTotal" type="text" class="inputline" id="GrandTotal" size="20" readonly="readonly"/></td>
                                      </tr>
                                      <tr class="light">
                                        <td height="30" colspan="4">&nbsp;</td>
                                        <td><span class="tabletitle">VAT</span></td>
                                        <td>&nbsp;</td>
                                      </tr>
                                      <tr class="dark">
                                        <td height="30" colspan="4">&nbsp;</td>
                                        <td><span class="tabletitle">Net Total </span></td>
                                        <td>&nbsp;</td>
                                      </tr>
                                    </tbody>
                                  </table>
Member Avatar
ddymacek
Posting Whiz
324 posts since Jun 2010
Reputation Points: 15 [?]
Q&As Helped to Solve: 68 [?]
Skill Endorsements: 0 [?]
 
0
 

At some point, unclear in your code, you are multiplying qty x rate for each item, so $item_total = qty x rate; although, I do not see this in your code here. anyway I am assuming this is happening in your while loop as you are doing each item. so prior to your while loop make a new variable $grand_total = 0;
inside your while loop after $item_total is calculated do this:

$grand_total += $item_total;  // <-- wherever $item_total comes from.
// when you want to display it, $grand_total should hold the values of all items.
Member Avatar
rpv_sen
Posting Whiz in Training
260 posts since Mar 2011
Reputation Points: 14 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 1 [?]
 
0
 

Hi

Thanks for your reply.

i have done the multiplication through Java script the code is below

<script type=text/javascript>
function multiply(id){
var a;
var b;
var c;
a = document.getElementById("rate" + id).value;
b = document.getElementById("required_qty" + id).value;
c = a * b
document.getElementById("total_rate" + id).value = Math.round(c*100)/100;
}

function getSum(){
                
				var val=document.getElementById("total_rate" + id).value;
                var sum=0;
                for(var  j=0;j<val.id;j++){
                    val=parseInt(val[j].value);
                    sum +=val;
                }

                alert("total is ="+sum);
               // str+="<span><input type='text' value="sum" /></span>";
            }

</script>

and i am trying to find out sum through getsum function as above.

Help me

Member Avatar
rpv_sen
Posting Whiz in Training
260 posts since Mar 2011
Reputation Points: 14 [?]
Q&As Helped to Solve: 21 [?]
Skill Endorsements: 1 [?]
 
0
 

Hi

I have solved my issues.

Thanks for your support

Question Answered as of 2 Years Ago by ddymacek, masterjiraya and paulrajj
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: