We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Setting the value using javascript after initialisation

Thread ID:

Created:

Updated:

Platform:

Replies:

125152 Jul 22,2016 07:40 AM Jul 26,2016 07:08 AM ASP.NET MVC 1
loading
Tags: NumericTextbox
Lewis Hamill
Asked On July 22, 2016 07:40 AM

I have declared a numeric text box in my markup:

<ej:NumericTextBox ID="ntbTotal" runat="server" MinValue="0" WatermarkText="" 
                                        ReadOnly="true" CssClass="stock-open-total" ShowSpinButton="false" />

I want to access the textbox in javascript and update the value as a sum of other numeric text boxes with the class "stock-open-val".

So far I have come up with the code below. Getting the values works fine however I haven't found a way to select the total numeric text box and update the value.

function stockOpeningCalc(inst, args) {
    var openValTBs = $(".stock-open-val .e-numerictextbox");

    var openTotal = 0;

    for (var i = 0; i < openValTBs.length; i++)
    {
        var value = openValTBs[i]["value"];
        if ($.isNumeric(value)) openTotal += parseFloat(value);
    }

    //set value here
}

Ashokkumar Balasubramanian [Syncfusion]
Replied On July 26, 2016 07:08 AM

Hi Lewis, 
 
Thanks for using Syncfusion Products. 
 
We have analyzed your requirement (“To set the Value to Numeric Textbox”).We can use the Value property to set the value for textbox control. 
 
Please refer the below code. 
[JAVASCRIPT] 
function myFunction(inst,args) { 
        var openValTBs = $(".stock-open-val .e-numerictextbox"); 
 
        var openTotal = 0; 
 
        for (var i = 0; i < openValTBs.length; i++) 
        { 
            var value = openValTBs[i]["value"]; 
            if ($.isNumeric(value)) openTotal += parseFloat(value); 
        } 
        $("#ntbTotal").ejNumericTextbox("instance").option({ value: openTotal }); 
} 
 
As per requirement, we have prepared a sample and the sample can be downloaded from the following location. 
Sample Location: Textboxes 
 
To know more about the api configuration, please refer the below link. 
 
Please let us know whether the provided sample is helpful in achieving your requirement or not. If you have any other queries, please get back to us with additional information, we will happy to assist you.  
 
Regards, 
Ashokkumar B

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;