...

View Full Version : Image issue?



yazan
07-28-2011, 09:46 AM
Hey,

I'm not very good with JavaScript, I'm a beginner. I'm wondering why my image won't appear?

This is the script:


<script>

function toggle5(showHideDiv, switchImgTag) {
var ele = document.getElementById(showHideDiv);
var imageEle = document.getElementById(switchImgTag);
if(ele.style.display == "block") {
ele.style.display = "none";
imageEle.innerHTML = '<img src="localhost/haha.jpg">';
}
else {
ele.style.display = "block";
imageEle.innerHTML = '<img src="localhost/haha.jpg">';
}
}
</script>

And this is the HTML:


<div id="headerDivImg">
<div id="titleTextImg">Click below!</div>
<a id="imageDivLink" href="javascript:toggle5('contentDivImg', 'imageDivLink');"><img src="localhost/haha.jpg"></a>
</div>
<div id="contentDivImg" style="display: none;">
<form>
<input type="text">
</form></div>


What's the issue here?

Thanks.

devnull69
07-28-2011, 10:12 AM
Is "localhost" your domain or a subfolder? If it is your domain, you'll have to fully qualify it using "http://" in front of it.

abduraooft
07-28-2011, 10:12 AM
What's the issue here?
have you got a live demo link?

yazan
07-28-2011, 10:23 AM
devnull69: It's not my domain, it's my subfolder.

abduraooft: No sorry, I don't know how to apply and create that. I'm just a beginner.

yazan
07-28-2011, 10:36 AM
Nevermind it was the http://!

THANK YOU!

yazan
07-28-2011, 10:45 AM
I have a new problem though...

I need two pictures...


<html>
<body>

<script>

function toggle5(showHideDiv, switchImgTag) {
var ele = document.getElementById(showHideDiv);
var imageEle = document.getElementById(switchImgTag);
if(ele.style.display == "block") {
ele.style.display = "none";
imageEle.innerHTML = '<img src="http://localhost/haha.jpg">';
}
else {
ele.style.display = "block";
imageEle.innerHTML = '<img src="http://localhost/hahatwo.jpg">';
}
}
</script>

<div id="headerDivImg">
<div id="titleTextImg">Click below!</div>
<a id="imageDivLink" href="javascript:toggle5('contentDivImg', 'imageDivLink');"><img src="http://localhost/haha.jpg"></a>
</div>
<div id="contentDivImg" style="display: none;">
<form>
<input type="text">
</form></div>

</body>
</html>

That's the whole script with the HTML with it.
How do I put in a second picture when I press the "first" picture?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum