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.
Syncfusion Feedback

Assign value from dropdownlist on change

Thread ID:

Created:

Updated:

Platform:

Replies:

130702 May 26,2017 05:32 PM UTC May 29,2017 07:09 AM UTC ASP.NET Core 1
loading
Tags: DropDownList
karen anderson
Asked On May 26, 2017 05:32 PM UTC

I have a dropdownlist which contains value, text and estimatedHours, how can I estimatedHours  to another input field on change?

<ej-drop-down-list id="serviceList"
                        ej-for="@Model.Trade.Service_Fk"
                        datasource="(IEnumerable<ServiceItem>)@Model.Services"
                        watermark-text="Select a service"
                        width="250px"
                        change="serviceList_change"
                        value="@Model.Trade.Service_Fk"
                        template="<div> ${text} </div> <div class='estHrs'>${estimatedHours} </div>">
                        <e-drop-down-list-fields text="text" estimatedHours="estimatedHours"/>
</ej-drop-down-list>

<ej-numeric-text-box id="EstimatedHours" decimal-places="1" ej-for="@Model.Trade.EstimatedHours" increment-step=".5" />

<script>
         function serviceList_change(args) {

             var dropdownObj = $("#serviceList").ejDropDownList('instance');

             ??????????????????????

         }
    </script>

Prince Oliver [Syncfusion]
Replied On May 29, 2017 07:09 AM UTC

Hi Karen,   
  
Thank you for contacting Syncfusion support.   
  
To set ‘estimatedHours’ field in dropdownlist datasource to another input field on change event, we need to get the ‘estimatedHours’ field based on the selected text value from the dropdownlist and then set it to numeric textbox. Kindly refer to the following code snippet.   

<script> 
    function serviceList_change(args) { 
        var dropdownObj = $("#serviceList").ejDropDownList('instance'); 
        var numericObj = $("#EstimatedHours").data("ejNumericTextbox"); 
        var selectedhour; 
        for(i = 0; i < dropdownObj.model.dataSource.length; i++) {  
            if (dropdownObj.model.dataSource[i].text == args.selectedText) {  
                selectedhour = dropdownObj.model.dataSource[i].EstimatedHours 
            } 
        } 
        numericObj.setModel({ value: selectedhour }); 
    } 
</script> 


Regards, 
Prince 


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.

Warning Icon 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.Close Icon

;