Change Sumo Select Dropdown Text and Value on Form Submission

2k Views Asked by At

I am having a form in which once I submit, all would go back blank as initial. I have implemented Sumo Select plugin for the dropdowns. When the form is submitted no changed on dropdown's value or text. No attempts are helping here. I will share the code below

HTML

<div class="col-lg-6">
    <div class="input-group mb-3">
        <select value="" name="_fromDrop" id="_fromDrop" class="SlectBox form-control">
            <?php echo load(); ?>
        </select>
    </div>
</div>

JQUERY FORM SUBMISSION

$(document).ready(function(e){
    $("#form").on('submit', function(e){
        e.preventDefault();
        $.ajax({
            type: 'POST',
            url: 'add.php',
            data: new FormData(this),
            dataType: 'json',
            contentType: false,
            cache: false,
            processData:false,
            async: false,
            autoUpload: false,
            success: function(response){
                $('.statusMsg').html('');
                if(response.status == 1){
                    $('#form')[0].reset(); //FORM TO RESET AFTER SUBMISSION
                    $('.statusMsg').html('<p class="alert alert-success">'+response.message+'</p>'); // REPONSE MESSAGE
                    
                    postOrderSave(); //TEST METHOD TO RESET DROPDOWN

                }else{
                    $('.statusMsg').html(alert(response.message));
                }
                $('#form').css("opacity","");
                $(".submit").removeAttr("disabled");
            }
        });
    });
});

Method to RESET

function postOrderSave(){
    //Order From
    $('#_fromDrop[value="Name List"]').text('Name List');
}

Where am I making the Mistake? Please help on this.

1

There are 1 best solutions below

0
Swati On BEST ANSWER

If you look at that plugin documentation to set selected value in your select-box you can use :

 $('select.SlectBox')[0].sumo.selectItem('Name List');