I am populating a form in a dialogue from values from a database query.One of the fields is a country field. I now want to set the value of a dropdown with the selected value.However, my code has no result. Even alerts placed in the code is not running.The code works in a plain html file, so it should work here as well. Or do I have to do this another way?/* myform_post.ftl */
new Alfresco.dashlet.MyApp("${args.htmlid}").setOptions(
{
"location" : "${location!''}",
"country" : "${country!''}",
}).setMessages(
${messages}
);
//]]>
function setSelectedIndex(s, v) {
for ( var i = 0; i < s.options.length; i++ ) {
if ( s.options[i].text === v ) {
s.options[i].selected = true;
/* s.value = v;
* s.selectedIndex = i;
*/
return;
}
}
}
setSelectedIndex(document.getElementById("${args.htmlid}-country"), "${country}");
:
:
<select name="country" id="${args.htmlid}-country" size="1" >
<option value="Albania">Albania</option>
<option value="Algeria">Algeria</option>
<option value="American Samoa">American Samoa</option>
<option value="Andorra">Andorra</option>
<option value="Angola">Angola</option>
:
</select