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

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -