Skip to main content
Inspiring
Apr 6, 2022 6:08 AM UTC
Answered

HTML5 Canvas - Combobox clear values

I have a combobox which is dynamically populated via JQuery AJAX with JSON.

 

How do I clear the values of that combobox to refesh it for new values?

 

 

    This topic is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    FlatChatAuthor
    Inspiring
    Apr 6, 2022 6:55 AM UTC

    I have tried in the following code:

     

    $('#patients_cbx').prop('selectedIndex',0);

     

    and also

     

    $('#patients_cbx').val('');

     

    I cannot find any reference from Adobe on doing this or a lot of other seemingly simple things...most frustrating!

     

    		$.ajax({
    			type: "POST",
    			url: 'scripts/get_patients.php',
    			dataType: 'json',
    			data: {
    				complexity: complexity
    			},
    			success: function (data) {
    				$('#patients_cbx').prop('selectedIndex',0);
    				console.log(complexity);
    				for (var i = 0; i < data.length; i++) {
    					$('#patients_cbx').append($("<option/>").attr("value", data[i].data).text(data[i].label));
    				}
    			}
    		});
    Translate
    FlatChatAuthor
    Inspiring
    Apr 7, 2022 12:39 AM UTC

    An answer on this question please?

    Translate
    FlatChatAuthorCorrect answer
    Inspiring
    Apr 8, 2022 1:00 AM UTC