Hi telerik,
I have an ASP Table with collection of RadNumericTextBoxes inside it. like this:
<asp:Table ID="tblMatrix" runat="server" CellSpacing="3" CellPadding="3">
<asp:TableRow runat="server" ID="tblBodyRow_1">
<asp:TableCell runat="server" ID="tblBodyCell_R1_C2" Width="75px">
<telerik:RadNumericTextBox ID="txtQty_R1_C2" runat="server" Skin="AsiSkin" EnableEmbeddedSkins="False"
Width="75px" Value="0">
<NumberFormat AllowRounding="false" KeepNotRoundedValue="true" DecimalDigits="0" />
</telerik:RadNumericTextBox>
</asp:TableCell>
.................. other cells
</asp:TableRow >
................ other rows
</asp:Table >
on blur event of each text box I need to calculate total of all values in all text boxes. How do I do it in javascript?
Currently I have an OnBlure event where I traverse all textboxes inside table trying to calc. the sum... however it looks like the rendered
RadNumericTextBox consists of more then one html input control and the value of the visible control is not numeric... Here is my code:
I have an ASP Table with collection of RadNumericTextBoxes inside it. like this:
<asp:Table ID="tblMatrix" runat="server" CellSpacing="3" CellPadding="3">
<asp:TableRow runat="server" ID="tblBodyRow_1">
<asp:TableCell runat="server" ID="tblBodyCell_R1_C2" Width="75px">
<telerik:RadNumericTextBox ID="txtQty_R1_C2" runat="server" Skin="AsiSkin" EnableEmbeddedSkins="False"
Width="75px" Value="0">
<NumberFormat AllowRounding="false" KeepNotRoundedValue="true" DecimalDigits="0" />
</telerik:RadNumericTextBox>
</asp:TableCell>
.................. other cells
</asp:TableRow >
................ other rows
</asp:Table >
on blur event of each text box I need to calculate total of all values in all text boxes. How do I do it in javascript?
Currently I have an OnBlure event where I traverse all textboxes inside table trying to calc. the sum... however it looks like the rendered
RadNumericTextBox consists of more then one html input control and the value of the visible control is not numeric... Here is my code:
///////////////////////// =========== OnBlur Events =========== ////////////////////////////////// |
function QtyTxt_OnBlur() |
{ |
var cntrlMtrxTable = $get('<%= tblMatrix.ClientID %>'); |
if (cntrlMtrxTable) |
{ |
CalculateMatrixTotals(cntrlMtrxTable); |
} |
} |
/////////////////////////////////// UTILITIES //////////////////////////////////////// |
////////////////////////////////////////////////////////////////////////////////////// |
/// Name: CalculateMatrixTotals() |
/// Function Type: Event |
/// Parameters: |
///////////////////////////////////////////////////////////////////////////////////// |
function CalculateMatrixTotals(cntrlMtrxTable) |
{ |
var cntrlTotalUsed = $get('<%= txtTotalUsed.ClientID %>'); |
var cntrlTotalLeft = $get('<%= txtTotalLeft.ClientID %>'); |
var cntrlCurrentLITotalQty = $get('<%= hdnCurrentLITotalQty.ClientID %>'); |
var sumOfMatrixQty = 0; |
var myInputArray = cntrlMtrxTable.getElementsByTagName("INPUT"); |
for (var i = 0; i < myInputArray.length; i++) |
{ |
var currInput = myInputArray[i]; |
if (currInput.type == "text" && currInput.style.visibility != 'hidden' && currInput.id.indexOf('txtQty_') >= 0) |
{ |
sumOfMatrixQty += currInput.value; |
} |
} |
if (cntrlTotalUsed && cntrlTotalLeft && cntrlCurrentLITotalQty) |
{ |
var LITotalQty = cntrlCurrentLITotalQty.value; |
cntrlTotalUsed.value = sumOfMatrixQty; |
cntrlTotalLeft.value = LITotalQty - sumOfMatrixQty; |
alert('cntrlTotalUsed.value = ' + cntrlTotalUsed.value); |
alert('cntrlTotalLeft.value = ' + cntrlTotalLeft.value) |
alert('sumOfMatrixQty = ' + sumOfMatrixQty); |
} |
} |
</script> |
</telerik:RadScriptBlock> |