Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

Show selected option in SelectBox using jQuery

Hello Friends,

jQuery-Ajax is getting popular day by day for updating the data of database in very effective manner. If you works with SelectBox and using jQuery-Ajax for updating the value of SelectBox in database. This can be done by calling jQuery-Ajax on onChange event  of SelectBox. Once the value is getting updated in database, you have to show that value selected in SelectBox. As the form is not submitted, it will not show database value selected with the code you had written in SelectBox.

Below is the way to make the SelectBox selected. You have to return the value of SelectBox in response of jQuery-Ajax call. Now write the below code in success: function(data) { .

$("#select_id option[value='"+data+"']").attr('selected', 'selected');

Above code will find the option with value of data. Once it found , it will be marked as "selected".

Share:

No Comments Yet.

Leave a Reply

Your email address will not be published.