This code should display 2 buttons Map
& Rainfall
.
Above that should be the text "Choose a display"
.
Once either button is clicked, it then displays either a google map image (If map button clicked) or a Rainfall image (If rainfall button clicked).
The issue I'm having is if I click the map button first, the text is swapped for the map, which is great, but then if I click the rainfall button, the image doesn't replace the map, it just displays under it.
Also if I click the rainfall button BEFORE the map button with the text displayed, then the image is displayed UNDER the text "Choose a display"
when I want it to be hidden after I click that button too.
Any help will be greatly appreciated.
HTML:
<p align="center"style="font-family:verdana;"id="googlemap">Choose a Main Display</p>
<p align="center"id="bommap"></p>
<p align="center">
<button type="button" onclick="mapFunction()">Map</button>
<button type="button" onclick="rainFunction()">Rainfall</button>
</p>
JavaScript:
function mapFunction() {
x = document.getElementById("googlemap"); // Find the element
x.innerHTML = '<iframe width="640" height="480" frameborder="0"scrolling="no" marginheight="0" marginwidth="0" src="https://www.google.com.au/maps?f=d&source=s_d&saddr=23+Burgundy+St,+Carseldine+QLD&daddr=90+Gilbert+Rd,+Grange+QLD+to:Narrowneck+Court+Surfers+Paradise,+204+Ferny+Ave,+Surfers+Paradise+QLD&hl=en&geocode=FfOeXv4d6qweCSn9XcBQSP2TazGVQ_0hH3aSYA%3BFRKQXf4d5_QeCSlRy4j_0lmRazEdtrkd8CRD0Q%3BFWXtVP4dWCUlCSGK90q-pKXOZCmv-18SewWRazGK90q-pKXOZA&aq=0&oq=Narr&sll=-27.422699,153.02411&sspn=0.004819,0.008272&t=h&mra=ls&ie=UTF8&ll=-27.555764,153.208466&spn=0.584401,0.878906&z=10&output=embed"></iframe>' // Change the content
}
function rainFunction() {
x = document.getElementById("bommap"); // Find the Element
x.innerHTML = '<img src="http://www.bom.gov.au/radar/IDR663.gif?20130517070843" border="0" alt="128 km Brisbane (Mt Stapylton) Radar" title="128 km Brisbane (Mt Stapylton) Radar">'
}