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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dropdownlist - Dynamic creation

Thread ID:





142054 Jan 16,2019 07:52 PM UTC Jan 18,2019 05:07 AM UTC ASP.NET Core - EJ 2 3
Tags: Dropdown List
Daniel Duvoisin
Asked On January 16, 2019 07:52 PM UTC

Hi support,

I'm trying to create a control dynamically with JS (ex: a dropdownlist), but i don't know how to do it.
When the user click on a button, i would create a dropdownlist automatically (or create 2, 3, 4 dropdownlist)


Prince Oliver [Syncfusion]
Replied On January 17, 2019 10:41 AM UTC

Hi Daniel, 

Thank you for using Syncfusion products. 

To create a DropDownList control dynamically with JS, kindly refer to the following code snippet. 

<script type="text/javascript"> 
    // Incremental variable to set unique ID attribute 
    var count = 0; 
    // Click handler 
    function onClick() { 
        // Incrementing the value upon every click 
        // Dynamically creating an input element 
        var inputEle = document.createElement('input'); 
        // Setting ID attibute to the dynamic inputs 
        inputEle.setAttribute('id', 'dropdown' + count); 
        // Appending the created element to the DOM 
        // Datasource for the DropDownList 
        var sportsData = ['Badminton', 'Cricket', 'Football', 'Golf', 'Tennis']; 
        // Rendering the DropDownList 
        var listObj = new ej.dropdowns.DropDownList({ 
            dataSource: sportsData, 
            placeholder: "Select games" 

We have attached a sample for your reference, please find the sample at the following location:  

Please let us know if you need any further assistance on this. 


Daniel Duvoisin
Replied On January 17, 2019 09:20 PM UTC

Hi Prince,

Thank you, it works great!


Prince Oliver [Syncfusion]
Replied On January 18, 2019 05:07 AM UTC

Hi Daniel, 

Most welcome. We are glad to help you. Please let us know if you need any further assistance on this. 



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon