www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] Invoice Total value Not working

Hybrid View

  1. #1
    Join Date
    Jun 2012
    Posts
    8

    resolved [RESOLVED] Invoice Total value Not working

    Code:
    <script type="text/javascript">
    function submitForm(form,newAction) {
        form.action = newAction + "";
        form.submit();                  
    }
    function calc(idx) {
    	
      var price = parseFloat(document.getElementById("cost"+idx).value)*
                  parseFloat(document.getElementById("qty"+idx).value);
    			  
    			  
    			  document.getElementById("price"+idx).value= isNaN(price)?"0.00":price.toFixed(2);
    			  
    			  
    			  var table = document.getElementById("dataTable");
    			  
    		      var rowCount = table.rows.length;
    				var s=rowCount-1;
    
    			for (var i=1;i<=s;i++) {
    				var total=0;
    				
    				  var e = parseFloat(document.getElementById("price"+i).value);
    				
    				    total += isNaN(e)?0:e;
    			  }
    			 
    			 document.getElementById("total").value=isNaN(total)?"0.00":total.toFixed(2);  
       
    }
    
    
        function deleteRow(tableID) {
            try {
            var table = document.getElementById(tableID);
            var rowCount = table.rows.length;
    
            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    table.deleteRow(i);
                    rowCount--;
                    i--;
                }
    
    
            }
            }catch(e) {
                alert(e);
            }
        }
    </script>
    HTML Code:
    <c:forEach items="${inlist.invoicelist}" var="addin" varStatus="status">
                    <TR>
                        
                        <TD width="2px">${status.count}</TD>
                        
                        <TD><select name="invoicelist[${status.index}].drug" onChange="submitForm(this.form,'findmedicine')" >
    					<option value="0">--Please Select--</option>
    					<c:if test="${!empty druglist}">
    					<c:forEach items="${druglist}" var="druglist">
    							<option value="${druglist.mid}" <c:if test="${druglist.mid eq addin.drug}"> selected="selected" </c:if> >${druglist.medicine}</option>		
    					</c:forEach>
    					</c:if>
    					
    			  </select>
    			                      <TD> <input   name="invoicelist[${status.index}].rate" id="cost<c:out value="${status.index}"/>" size="16"  value="${addin.rate}" onkeyup="calc('${status.index}')"/></TD>
    			  
                        <TD> <input  name="invoicelist[${status.index}].quantity"   id="qty<c:out value="${status.index}"/>" size="16" value="${addin.quantity}" onkeyup="calc('${status.index}')"/> </TD>
                        <TD> <input   name="invoicelist[${status.index}].netamount" id="price<c:out value="${status.index}"/>" size="16" value="${addin.netamount}"/>
                      <input type="hidden"  name="invoicelist[${status.index}].id"  size="16" value="${addin.id}"/>
                   <td><a href="reomoveitemnew?id=${addin.id}&invoiceid=${invoice.invoiceid}"><img src="../../images/damage.jpg" width="10" height="10" /></a></td>
    
                    </TR>
    </c:forEach>
    i call this java script in on key up " <input name="invoicelist[${status.index}].quantity" id="qty<cut value="${status.index}"/>" size="16" value="${addin.quantity}" onkeyup="calc('${status.index}')"/> "

    but this not working for total amount only
    plz give me the good replay friends

    thank you

  2. #2
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,264
    Display the total in the loop with a new line
    Code:
           total += isNaN(e)?0:e;
             if (window.console) console.log(e+'  total:'+total)
    Open the console (F12 with IE)
    Last edited by 007Julien; 07-03-2013 at 06:40 AM.

  3. #3
    Join Date
    Jun 2012
    Posts
    8
    thank you friend.

    <form action="saveinvoice" method="post" >
    <form:form action="saveinvoice" commandName="invoice" method="post" >
    <TABLE >
    <tr><TD width="100px"><label>Invoice Id</label></TD><TD><form:input path="invoiceid"/></TD>
    <TD width="100px"><label>Invoice Date</label></TD><TD><form:input path="date"/></TD>
    <TD width="100px"><label>Total Amount</label></TD><TD><form:input readonly="readonly" id="total" path="total"/></TD>
    </tr>
    </TABLE>
    <TABLE id="dataTable" >

    <TR>
    <TH>No</TH>
    <TH>Drug</TH>
    <TH>Rate</TH>
    <TH>Quantity</TH>
    <TH formula="cost*qty"summary="sum">Price</TH>
    </TR>
    <c:forEach items="${inlist.invoicelist}" var="addin" varStatus="status">
    <TR>

    <TD width="2px">${status.count}</TD>

    <TD><select name="invoicelist[${status.index}].drug" onChange="submitForm(this.form,'findmedicine')" >
    <option value="0">--Please Select--</option>
    <c:if test="${!empty druglist}">
    <c:forEach items="${druglist}" var="druglist">
    <option value="${druglist.mid}" <c:if test="${druglist.mid eq addin.drug}"> selected="selected" </c:if> >${druglist.medicine}</option>
    </c:forEach>
    </c:if>

    </select>
    <TD> <input name="invoicelist[${status.index}].rate" id="cost<cut value="${status.index}"/>" size="16" value="${addin.rate}" onkeyup="calc('${status.index}')"/></TD>

    <TD> <input name="invoicelist[${status.index}].quantity" id="qty<cut value="${status.index}"/>" size="16" value="${addin.quantity}" onkeyup="calc('${status.index}')"/> </TD>
    <TD> <input name="invoicelist[${status.index}].netamount" id="price<cut value="${status.index}"/>" size="16" value="${addin.netamount}"/>
    <input type="hidden" name="invoicelist[${status.index}].id" size="16" value="${addin.id}"/>
    <td><a href="reomoveitemnew?id=${addin.id}&invoiceid=${invoice.invoiceid}"><img src="../../images/damage.jpg" width="10" height="10" /></a></td>

    </TR>
    </c:forEach>



    </TABLE>
    <input type="button" value="Add" onClick="submitForm(this.form, 'Saveitems')" />
    <input type="submit" value="Confirm"/>
    </form:form>
    </form>

    this is my form i could not find my error
    can u plz help
    Last edited by mathu; 07-03-2013 at 07:26 AM.

  4. #4
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,264
    It is impossible to guess the HTML code obtained by loading the page on a server ! Use the developers tools in your broswer... Or give the resulting source code.

  5. #5
    Join Date
    Jun 2012
    Posts
    8
    thank you 007Julien
    i get the out put correctly
    Last edited by mathu; 07-03-2013 at 11:04 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles