Hi there,
Glad to see that you are getting into the world of JS
As felgall says, an alert is not really the way to go. More on that later.
First, let’s look at how we can tidy up the code.
Start off by removing the reference to select2, it’s not needed.
Then let’s define an object literal and assign the text you wish to display when the dropdown changes, to numerical keys:
var select1 = document.getElementById("select1"),
texts = {
1: "You play in the Beckett League ...",
2: "You play in the Craven and District ...",
3: "You play in the Craven and District ...",
4: "You play in the Craven and District ...",
5: "You play in the Craven and District ..."
};
Then change the select1.onchange event handler thus:
select1.onchange = function(){
alert(texts[this.value]);
};
Already, that’s much neater.
Now, let’s define a <div> element below the select element to insert the result into:
<div id="result"></div>
Then, let’s get a reference to it and use JavaScript’s innerHTML function to change its content.
results = document.getElementById("results");
select1.onchange = function(){
results.innerHTML = texts[this.value];
};
Here’s everything together:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Dropdown example</title>
</head>
<body>
<div>
<label for="select1">Select 1</label>
<select id="select1">
<option>Please select something</option>
<option value="1">Beckett League</option>
<option value="2">Craven and District League Premier Division</option>
<option value="3">Craven and District League Division One</option>
<option value="4">Craven and District League Division Two</option>
<option value="5">Craven and District League Division Three</option>
</select>
</div>
<div id="results"></div>
<script>
var select1 = document.getElementById("select1"),
results = document.getElementById("results"),
texts = {
1: "You play in the Beckett League . The Beckett League isn't currently a part99 of the football pyramid. This means that your team would have to move leagues if you were to progress to the football league.",
2: "You play in the Craven and District League Premier Division . The Craven and District League Premier Division league sits at level 14 of the football pyramid. If you were to win promotion every year, it would take you 10 years to reach the Football League (League 2) . It would take 14 years to reach the Premier League.",
3: "You play in the Craven and District League Division One . The Craven and District League Division One league sits at level 15 of the football pyramid. If you were to win promotion every year, it would take you 11 years to reach the Football League (League 2) . It would take 15 years to reach the Premier League.",
4: "You play in the Craven and District League Division Two . The Craven and District League Division Two league sits at level 16 of the football pyramid. If you were to win promotion every year, it would take you 12 years to reach the Football League (League 2) . It would take 16 years to reach the Premier League.",
5: "You play in the Craven and District League Division Three . The Craven and District League Division Three league sits at level 17 of the football pyramid. If you were to win promotion every year, it would take you 13 years to reach the Football League (League 2) . It would take 17 years to reach the Premier League."
};
select1.onchange = function(){
results.innerHTML = texts[this.value];
};
</script>
</body>
</html>
Hope that helps.