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

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -