I need help with a piece of Html code I have. It's a list of countries, and what I want is to show an alert when one or more countries are selected to display which ones were chosen. I'm working with JavaScript only and don't want to use Jquery or PHP.
<select name= "countrylaw">
<option value = "1">Afghanistan</option>
<option value = "2">Albania</option>
<option value = "3">Algeria</option>
<option value = "4">Andorra</option>
<option value = "5">Angola</option>
<option value = "6">Antigua & Deps</option>
<option value = "7">Argentina</option>
<option value = "8">Armenia</option>
Below is my JavaScript code, but it doesn't seem to be working:
var select1 = document.getElementsByName("country");
var selected1 = [];
for (var i = 0; i < select1.length; i++)
{
if (select1.options[i].selected)
{
alert("File Selected for " + select1.options[i].value +" ")
}
}