/    Sign up×
Community /Pin to ProfileBookmark

[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>[/CODE]

[code=html]<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>
[/code]

i call this java script in on key up ” <input name=”invoicelist[${status.index}].quantity” id=”qty<c:out 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

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@007JulienJul 03.2013 — Display the total in the loop with a new line
[CODE] total += isNaN(e)?0:e;
if (window.console) console.log(e+' total:'+total)
[/CODE]
Open the console (F12 with IE)
Copy linkTweet thisAlerts:
@mathuauthorJul 03.2013 — 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<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>



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

</form:form>

</form>[/QUOTE]



this is my form i could not find my error

can u plz help
Copy linkTweet thisAlerts:
@007JulienJul 03.2013 — 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.
Copy linkTweet thisAlerts:
@mathuauthorJul 04.2013 — thank you 007Julien

i get the out put correctly
×

Success!

Help @mathu 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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