option in javascript code example
Example 1: how to echo data into an option tag as a link
<select name="forma" onchange="location = this.value;">
<option value="Home.php">Home</option>
<option value="Contact.php">Contact</option>
<option value="Sitemap.php">Sitemap</option>
</select>
Example 2: javascript option
var s = document.getElementById('s');
var options = [ 'zero', 'one', 'two' ];
options.forEach(function(element, key) {
if (element == 'zero') {
s[s.options.length] = new Option(element, s.options.length, false, false);
}
if (element == 'one') {
s[s.options.length] = new Option(element, s.options.length, true, false);
}
if (element == 'two') {
s[s.options.length] = new Option(element, s.options.length, false, true);
}
});