Thanks for coming back, and ye whats happening is that on page load for continents in the form of graphical maps are displayed, and the idea is when any of the continents are clicked, the relevant countries are displayed, so what the display:none is doing is saying close all the countries up except for this one that you clicked.
As an example and its very similar is here - The maps
Its the map area at the bottom.
What I could do is put up a bigger version of what I have.
These are the continents
<div class="section group">
<div class="col span_1_of_4">
<a onClick="showHideContinentCountries(1);" id="americasMap">
<img src="/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Americas_Grey.png"
onMouseOver="this.src='/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Americas.png'"
onMouseOut="this.src='/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Americas_Grey.png'" />
</a>
</div>
<div class="col span_1_of_4">
<a onClick="showHideContinentCountries(2);" id="europeMap">
<img src="/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Europe_Grey.png"
onMouseOver="this.src='/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Europe.png'"
onMouseOut="this.src='/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Europe_Grey.png'" />
</a>
</div>
<div class="col span_1_of_4">
<a onClick="showHideContinentCountries(3);" id="middleEastMap">
<img src="/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Middle_East_&_Africa_Grey.png"
onMouseOver="this.src='/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Middle_East_&_Africa.png'"
onMouseOut="this.src='/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Middle_East_&_Africa_Grey.png'" />
</a>
</div>
<div class="col span_1_of_4">
<a onClick="showHideContinentCountries(4);" id="asiaMap">
<img src="/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Asia_Grey.png"
onMouseOver="this.src='/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Asia.png'"
onMouseOut="this.src='/Images/Locale-Specific/@(LH.CurrentLanguageID)/Contact/Asia_Grey.png'" />
</a>
</div>
</div>
This then is the countries that relate to the first continent, so there 4 of these
<div id="continent1Countries">
<button class="showSelectedCountryHideOtherCountries" data-continent-position="1" data-countryinContinent-position="Countrya">
@LH.GetText(LH.SystemComponent.CristalStandards, "btnBrazil_Contact")
</button> |
<button onClick="showSelectedCountryHideOtherCountries('1','Countryb');">
@LH.GetText(LH.SystemComponent.CristalStandards, "btnCostaRica_Contact")
</button> |
<button onClick="showSelectedCountryHideOtherCountries('1','Countryc');">
@LH.GetText(LH.SystemComponent.CristalStandards, "btnDominicanRepublic_Contact")
</button> |
<button onClick="showSelectedCountryHideOtherCountries('1','Countryd');">
@LH.GetText(LH.SystemComponent.CristalStandards, "btnJamaica_Contact")
</button> |
<button onClick="showSelectedCountryHideOtherCountries('1','Countrye');">
@LH.GetText(LH.SystemComponent.CristalStandards, "btnMexico_Contact")
</button>
</div>
<div id="continent2Countries">
<button onClick="showSelectedCountryHideOtherCountries('2','Countrya');">@LH.GetText(LH.SystemComponent.CristalStandards, "btnUK_Contact")</button> |
<button onClick="showSelectedCountryHideOtherCountries('2','Countryb');">@LH.GetText(LH.SystemComponent.CristalStandards, "btnFrance_Contact")</button> |
<button onClick="showSelectedCountryHideOtherCountries('2','Countryc');">@LH.GetText(LH.SystemComponent.CristalStandards, "btnGreece_Contact")</button> |
<button onClick="showSelectedCountryHideOtherCountries('2','Countryd');">@LH.GetText(LH.SystemComponent.CristalStandards, "btnItaly_Contact")</button> |
<button onClick="showSelectedCountryHideOtherCountries('2','Countrye');">@LH.GetText(LH.SystemComponent.CristalStandards, "btnSpain_Contact")</button> |
<button onClick="showSelectedCountryHideOtherCountries('2','Countryf');">@LH.GetText(LH.SystemComponent.CristalStandards, "btnTurkey_Contact")</button>
</div>
Then I have this function which works with the continents,
function showHideContinentCountries(ContinentMapPositionInt) {
var numberofContinents = 4;
for (i = 1; i <= numberofContinents; i++) {
document.getElementById('countryWrapperCountrya' + i).style.display = 'none';
if (i == ContinentMapPositionInt) {
document.getElementById('continent'+ i +'Countries').style.display = 'block';
document.getElementById('continent' + i).style.display = 'block';
} else {
document.getElementById('continent' + i + 'Countries').style.display = 'none';
document.getElementById('continent' + i).style.display = 'none';
}
}
return false;
}
And then the function we working on now is dealing with the showing of the countries within the continents
function showSelectedCountryHideOtherCountries(continentNumber, countryLetter) {
var countriesInContinents = ["Countrya", "Countryb", "Countryc", "Countryd", "Countrye", "Countryf", "Countryg"];
var numberofContinents = 4;
for (i = 1; i <= numberofContinents; i += 1) {
document.querySelectorAll(countriesInContinents.map(country => "#countryWrapper" + country + i))
.forEach(sub => sub.style.display = "none");
}
document.querySelector("#countryWrapper" + countryLetter + continentNumber).style.display = "block";
return false;
}
Which with your help is slowly morphing into
const countryBtns = document.querySelectorAll('.showSelectedCountryHideOtherCountries');
countryBtns.forEach(btn =>
btn.addEventListner('click', countryBtnClickHandler)
)
function countryBtnClickHandler() {
const clickedPos = this.data.set.position
const clickedCountry = this.dataset.countryinContinent
var countriesInContinents = ["Countrya", "Countryb", "Countryc", "Countryd", "Countrye", "Countryf", "Countryg"];
var numberofContinents = 4;
for (i = 1; i <= numberofContinents; i += 1) {
document.querySelectorAll(countriesInContinents.map(country => "#countryWrapper" + country + i))
.forEach(sub => sub.style.display = "none");
}
document.querySelector("#countryWrapper" + clickedCountry + clickedPos).style.display = "block";
return false;
}
So just trying to put your saying into that last function, Im part the way there
I have changed the data identifies to below
<button class="showSelectedCountryHideOtherCountries" data-continentPosition="1" data-countryinContinentPosition="Countrya">
const countryBtns = document.querySelectorAll('.showSelectedCountryHideOtherCountries');
countryBtns.forEach(btn =>
btn.addEventListner('click', countryBtnClickHandler)
)
function countryBtnClickHandler() {
const clickedPos = this.data.continentPosition
const clickedCountry = this.data.countryinContinentPosition
alert(clickedPos);
When I click the one I have adapted I’m not getting the alert, was just trying ot work through the information thats being sent to learn from this too