Create html tags using JQuery -


i need create option tags inside select tag using jquery,

this select tag:

<select id="tickets-room" style="height: 20px; width:200px; display: inline-block; margin-top:30px;" onchange="refreshrooms(this.value);"> </select> 

each option tag need id 1,2,3,4

each option tag should recieve "resp[].key" text.

i don't know if makes sense, don't know how explain well, code have of elements need. resp.key name need text inside option tags, resp.value url need place on button outside select tag.

function refreshrooms(city){     $.ajax('/services/tickets/<%= movieid %>?city=' + city).done(         function(resp){             alert(resp.length);             console.log(resp[0].key + " " + resp[0].value);          }     );       } 

use jquery.append():

function refreshrooms(city){     $.ajax('/services/tickets/<%= movieid %>?city=' + city).done(         function(resp){             var sel = $("#tickets-room");              (var = 0; < resp.length; i++) {                 sel.append('<option value="' + resp[i].key + '">' + resp[i].value + '</option>');             }         }     );       } 

Comments

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -