I have an html file that contains the following code :
<select id="gouv" name="gouv">
...some options here...
</select>
and the following jQuery code :
$('#gouv option[value="myvalue"]').attr("checked","checked");
this as you certainly know sets the option with the value "myvalue" to checked which works perfectly.
Now the problem is, I don't know the value of the option I want to set as checked because this value is a result of some function which is stored within a global variable. For simplification sake, after long debugging, I reduced the problem to the following :
var ident="myvalue";
$('#gouv option[value=ident]').attr("checked","checked");
and this code doesn't work !
I would like to know why it doesn't work, can't we pass a value as a variable ? And is there any workaround to this ?