javascript - dwr addoptions with associative array -
i have associative array.i want able add options dropdown using associative array key value option , array key text of option element.
var associativearray = new array(); associativearray['city'] = "portland"; associativearray['state'] = "oregon"; associativearray['country'] = "united states"; dwr.util.addoptions(makeid3.id,associativearray);
doing above creates options elements text , value :
<option value="city,portland">city,portland</option>
however expecting following:
<option value="city">portland</option>
how can achieve above dwr , associative arrays.could suggest?
use object rather array:
var associativearray = { city: "portland", state: "oregon", country: "united states" }; dwr.util.addoptions(makeid3.id, associativearray, false);
or if want add properties dynamically, use:
var associativearray = {}; associativearray['city'] = "portland"; associativearray['state'] = "oregon"; associativearray['country'] = "united states";
see documentation. treats array argument differently object.
Comments
Post a Comment