Posts tagged “javascript”

Add an <option> to a <select> using Mootools

Sunday, December 6th, 2009
var newoption = new Option("option html", "option value");
try
{
	$('myselect').add(newoption, null);
}
catch (err)
{
	$('myselect').add(newoption);
}

To select the newly created option:

newoption.setProperty('selected', 'selected');