Hello all,
I have a gridview with a few columns. They are price, qty, discount and total price. What needs to happen is that the user enters a qty and price, the total price is automatically calculated. If the user enters a discount the total price is updated. This is per edit row.
On the Vb side of things i have setup the required attributes in the GridView1_RowDataBound subroutine:
Dim txtListPrice As TextBox = CType(e.Row.FindControl("txtListPrice"), TextBox)
txtListPrice.Attributes.Add("onkeyup", "RowCal()")
Dim txtQty As TextBox = CType(e.Row.FindControl("txtQty"), TextBox)
txtQty.Attributes.Add("onkeyup", "RowCal()")
Dim txtDiscount As TextBox = CType(e.Row.FindControl("txtDiscount "), TextBox)
txtDiscount .Attributes.Add("onkeyup", "RowCal()")
The problem is on the JavaScript side, which I have limited knowledge on:
function RowCal()
{
var ListPrice = document.getElementById(txtListPrice);
var Qty = document.getElementById(txtQty);
var Total = document.getElementById(txtTotal);
var num = new Number(0);
{
num = ListPrice.value * Qty.value
Total.Value = num.toFixed(2)
{
}
The JavaScript is not finding the text boxes in the gridview. I have made the columns into templatefields.
I have used JavaScript to calculate values from normal textboxs on the webpage, just not from in a gridview.
Any help will be appreciated.