Update the select box after adding a new entry
I have two jsp pages add.jsp and view.jsp. There is a dropdown list with all userids on view page which will be automatically fetched from database when the page loads (I'm using document.ready event to retrieve the values).
When i add a new user on add.jsp page and click submit, it will redirect to view.jsp page with a success message. However, the dropdown will not show the new userid added. I have to close and re-run the project so that it appears next time.
How to append the select box with newly added user ?
Since you are fetching the vales from database on page load your dropdown will not be getupdated untill page reloads.. if want to update with out refresh what you need to do is capture userid from textbox on submit click you need to append for drop down of if userid generated by database return updated data from your controller on sucess of ajax bind it to dropdown
var newOption = $('<option value="'+yournewvalue+'">'+yournewvalue+'</option>'); $('#yourdropdownid').append(newOption);