I am using JQuery to dynamically (based on user choice) create tag. User enters require options in a text box and my code creates select tag of it. Script is:
Slight amendment to the answer by Ravi - appending each element one by one is a surprisingly high cost operation.
var s = $(""); var opts = []; for(var val in data) { opts.push( $("", {value: val, text: data[val]})); } opts.appendTo(s);