Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
53
rated 0 times [  58] [ 5]  / answers: 1 / hits: 26511  / 7 Years ago, tue, february 21, 2017, 12:00:00

I am using a form in a modal where i add new fields to the select box and would like to refresh the select box such that the new options are added to it. And this without reloading the entire page . Can someone please tell me if this is possible or not and if it is how do i go about it.


More From » jquery

 Answers
18

Check this,





$(document).ready(function(){
$(#test).append($('<option>', {value: 2,text: 'Two'}));
});

<script src=https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js></script>
<select id=test>
<option value=1>One</option>
</select>





Give it a try, it should work.


[#58840] Monday, February 20, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
seth

Total Points: 307
Total Questions: 114
Total Answers: 96

Location: Kenya
Member since Mon, Jun 14, 2021
3 Years ago
;