My code
var row2 =<?php echo json_encode($_SESSION['row2']) ?>;
for (var i = 0; i < row2.length; i++) {
if(row2[i][0] == x) {
var select = document.getElementById("mTask");
select.options[select.options.length] = new Option(row2[i][2], row2[i][1]);
}
}
and it generates this in html
<select id="mTask" size="12">
<option value="0">Rätt eller fel!</option>
<option value="1">A Valles Verktygsaffär</option>
<option value="2">A Stina för dagbok</option>
<option value="3">A Dagbok för cykelverkstad</option>
<option value="4">A Dagbok för elfirma</option>
<option value="5">A Dagbok för innebandyklubb</option>
</select>
I would like the looks like this, is it possible?
<option ondblclick="mainLink(270)">Rätt eller fel!</option>
You can pass
thisinto the function which will reference the selected option. I only added it for the second choice.Here is a better solution. Bind a single function to the select list and then use the data-attribute to store the 270 number.
http://jsfiddle.net/sUqVV/1/
OLD
http://jsfiddle.net/sUqVV/