I was able to come up with this working example. It might not be the best, but it works. I'm sure others could write you a more comprehensive piece of code.
PHP Code:
<!DOCTYPE html>
<select id="continents">
<optgroup label="continents">
<option id="1">Asia</option>
<option id="2">Africa</option>
<option id="3">EU</option>
</optgroup>
</select>
<!-- Default policy should be initialised here. -->
<div id="privacy_policy"><a href="asiapolicy.html">Privacy Policy</a></div>
<script type="text/javascript">
document.getElementById("continents").addEventListener("change", change, false);
function change()
{
// Get ID of selected <option>.
var id = document.getElementById("continents");
var id = parseInt(id.options[id.selectedIndex].id);
// 2D array to keep continents in.
var continents = new Array(new Array());
// HREF text. Not necessary but useful if links always the same name.
var privacy = "Privacy Policy";
// Inisialise each elemennt to a new link.
continents[0][0] = "<a href='/asia_policy.html'>" + privacy + "</a>";
continents[0][1] = "<a href='/africa_policy.html'>" + privacy + "</a>";
continents[0][2] = "<a href='/eu_policy.html'>" + privacy + "</a>";
// Switch logic.
switch(id)
{
case 1:
{
document.getElementById("privacy_policy").innerHTML = continents[0][0];
break;
}
case 2:
{
document.getElementById("privacy_policy").innerHTML = continents[0][1];
break;
}
case 3:
{
document.getElementById("privacy_policy").innerHTML = continents[0][2];
break;
}
}
}
</script>
Bookmarks