I have this strange problem in JQuery. I try to set a value to a dropdown dinamically, so I have this code:
$('#activity').val(idValue);
//or this way:
$('#activity').val("'"+idValue+"'");
but it does not work. However, if I’m setting the value “statically” then it works:
$('#activity').val('23');
So, why does not accept the value from the variable? Or what am I doing wrong? Thanks!
UPDATE
I have tried the code in jsfiddle and it does work. It seems that the problem was related to the JSON data i was parsing. Thanks for the help!
What do you get if you alert idValue?
Alternatively, I would also try attr().