Does this work? $('#select_project').html(options).attr({ size: ''+dropsize });
-Mike p.s. I note that you're taking care to use double quotes for your HTML attributes - that's a Good Thing. A suggestion: Instead of having to keep track of when to use double quotes for your JavaScript strings and when to use single quotes (because there's a double quote inside the string), I've found it easier to simply use single quotes for all of my JavaScript strings - then I only have to switch to double quoted strings in the much rarer cases where I need a single quote inside the string. (Of course you can always use backslash, but that's ugly.) > How do I dynamically change size of select box depending on > the number of responses retreived froma getJSON [code] > $.getJSON("select.php", > {project:"%" }, function(json){ > var dropsize=json.length +2; > var options = ""; > options += '<option value="%">All Projects</option>'; > for (var i = 0; i < json.length; i++) { > options += '<option value="'+json[i]['project']+'">'+json[i] > ['project']+'</option>'; > } > $("#select_project").html(options); > [/code] > now I want to set the select box to have a size=dropsize for > example if the getJSON returned 8, dropsize=8 and the select > would look like > > <select id="select_project" name="select_project" size="8">