javascript - Jquery addOption Problems -
val1 = "1"; text1 = "the text"; var myoptions = { val1 : text1 } $("#map_element_map_element_folder_id").addoption(myoptions, true);
i have script. when run option added select box is
text = "the text" <- 1 correct
value = 'val1' <- not supposed this, supposed fill "1", because declare val1 = "1" in top of script
anyone have idea happen in here?
the way defining object, may expect var1 set key value defined var1 variable. dynamic object key assignment, have use bracket style:
var myoptions = {}; myoptions[var1] = text1;
Comments
Post a Comment