RikudoSage
Member
Hi there, I am wanting to create an onclick if statement that outputs the document.write information into a div class that is located in the same page.
here is the code samples:
If statement with document.write:
<script type="text/javascript">
function clickFunc(id){
if (id == songs)
{
document.write("hello world");
}
else if(id == gallery)
{
document.write("hello gallery");
}
}
</script>
onclick function to click it:
<div class = "gallery">
<img src="enterButton.png" id="gallery" onclick="clickFunc(gallery)" />
</div>
the div i want it to go into:
<div class = "mainContent">
<script type="text/javascript">
document.write("clickFunc(id)");
</style>
</div>
everything works except the document.write information going into the div class, it just opens a whole new page.
I hope that makes sense and someone can help me because it is doing my head in!!
here is the code samples:
If statement with document.write:
<script type="text/javascript">
function clickFunc(id){
if (id == songs)
{
document.write("hello world");
}
else if(id == gallery)
{
document.write("hello gallery");
}
}
</script>
onclick function to click it:
<div class = "gallery">
<img src="enterButton.png" id="gallery" onclick="clickFunc(gallery)" />
</div>
the div i want it to go into:
<div class = "mainContent">
<script type="text/javascript">
document.write("clickFunc(id)");
</style>
</div>
everything works except the document.write information going into the div class, it just opens a whole new page.
I hope that makes sense and someone can help me because it is doing my head in!!