passing values of dropdown to textbox

后端 未结 1 637
一向
一向 2021-01-19 20:08

I have got a dropdownlist, a submit button and a textbox in my view. I want to pass the selected value of dropdownlist to the textbox when the submit button is clicked or on

相关标签:
1条回答
  • 2021-01-19 20:36

    I want to pass the selected value of dropdownlist to the textbox when the submit button is clicked or onChange event of dropdownlist

    $(function() {
        var selectedValue = ''; // declare variable here
    
        // on drop down change
        $('#ddlComp').change(function() {
            selectedValue = $(this).val(); // store value in variable
            $('#txtCompName').val(selectedValue); // update on change
        });
    
        // on submit button click
        $('input[type=submit]').click(function(){
            $('#txtCompName').val(selectedValue); // update on submit button
        });
    });
    
    0 讨论(0)
提交回复
热议问题