Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Tuesday, 23 December 2014

To Check Decimal Point Validation, calculate Amount in Grid control based on selected DropDown Value

<script language="javascript">
    
        function CalculateTotalsInGrid(id) {
            var txtControl = document.getElementById(id);
                var NumberEntered = txtControl.value;
                var count = 0;
                var LastIndexOfDot = 0;
                for (var i = 0; i < NumberEntered.length; i++) {
                    if (NumberEntered[i] == '.') {
                        count = count + 1;
                        if (count == 2) {
                            LastIndexOfDot = i;
                        }
                    }
                }
                if (LastIndexOfDot > 0) {
                    document.getElementById(id).value = NumberEntered.substring(0, LastIndexOfDot);
                }
                var totalDoll=0;
                var val1=1;
                if(efg != "INR")
                {                  
                    val1 = parseFloat(document.getElementById('<%=txtExchangerate_TEB.ClientID%>').value);
                }
                var gdv = document.getElementById('<%=gdvExpenseSummary_Travel_TEB.ClientID%>');
                for (var i = 1; i < gdv.rows.length; i++) {
                    var Curramnt =parseFloat(gdv.rows[i].cells[8].childNodes.item(0).value);
                    var date = gdv.rows[i].cells[1].childNodes.item(0).value;
                    var ModeOfTransport = gdv.rows[i].cells[4].childNodes.item(0).value;
                    if (trim(date, " ") != "" && trim(ModeOfTransport, " ") != "")
                    {
                        totalDoll+=Curramnt;
                        gdv.rows[i].cells[9].childNodes.item(0).value =parseFloat(val1 * Curramnt);
                        gdv.rows[i].cells[9].childNodes.item(0).focus();
                    }
                    else
                    {
                        if(date == "")
                        {
                        alert('Please Select Date at Sr.No'+i);
                        }
                        else if(ModeOfTransport == "")
                        {
                        alert('Please Select ModeOfTransport at Sr.No'+i);
                        }
                    }
                }

                var efg=document.getElementById('<%=ddlCurr_Travel_TEB.ClientID%>').value;
                if(efg != "INR")
                {
                var gdv2 = document.getElementById('<%=txtConveyExpenseDyn_Travel_TEB.ClientID%>');
                gdv2.value=parseFloat(totalDoll);
                }
        }


No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.