Q:

Why is my javascript function failing?

What I want this code to do is display a button called Map. And above that some text should read "Chose a display". Then once that 'Map' button is clicked, it then displays a google map image through the  tags. 
<html>
<head>

<title>Random</title>

</head>
<body>

<p align="center"style="font-family:verdana;"id="googlemap">
Choose a Display
</p>

<script>
function mapFunction()
{
x=document.getElementById("googlemap");  // Find the element
x.src="<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0"     marginwidth="0" https://www.google.com.au/maps?f=d&amp;source=s_d&amp;saddr=23+Burgundy+St,+Carseldine+QLD&amp;daddr=90+Gilbert+Rd,+Grange+QLD+to:Narrowneck+Court+Surfers+Paradise,+204+Ferny+Ave,+Surfers+Paradise+QLD&amp;hl=en&amp;geocode=FfOeXv4d6qweCSn9XcBQSP2TazGVQ_0hH3aSYA%3BFRKQXf4d5_QeCSlRy4j_0lmRazEdtrkd8CRD0Q%3BFWXtVP4dWCUlCSGK90q-pKXOZCmv-18SewWRazGK90q-pKXOZA&amp;aq=0&amp;oq=Narr&amp;sll=-27.422699,153.02411&amp;sspn=0.004819,0.008272&amp;t=h&amp;mra=ls&amp;ie=UTF8&amp;ll=-27.555764,153.208466&amp;spn=0.584401,0.878906&amp;z=10&amp;output=embed"></iframe>;    // Change the content
}
</script>

<button type="button" onclick="mapFunction()">Map</button>

</body>
</html>

A:

I think you mean innerHTML
var x = document.getElementById("googlemap");  // Find the element
x.innerHTML = '<iframe src="url here" ...></iframe>';

Since the HTML contains ", you can either escape them with \ or just wrap the entire string with single quotes '.
Also, you forgot the src for the iframe.

