Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Image issue?

  1. #1
    New Coder
    Join Date
    Jun 2011
    Posts
    66
    Thanks
    17
    Thanked 0 Times in 0 Posts

    Image issue?

    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:

    PHP Code:
    <script>

    function 
    toggle5(showHideDivswitchImgTag) {
            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:

    PHP Code:
    <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.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    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.

  • Users who have thanked devnull69 for this post:

    yazan (07-28-2011)

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    What's the issue here?
    have you got a live demo link?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    New Coder
    Join Date
    Jun 2011
    Posts
    66
    Thanks
    17
    Thanked 0 Times in 0 Posts
    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.

  • #5
    New Coder
    Join Date
    Jun 2011
    Posts
    66
    Thanks
    17
    Thanked 0 Times in 0 Posts
    Nevermind it was the http://!

    THANK YOU!

  • #6
    New Coder
    Join Date
    Jun 2011
    Posts
    66
    Thanks
    17
    Thanked 0 Times in 0 Posts
    I have a new problem though...

    I need two pictures...

    PHP Code:
    <html>
    <
    body>

    <
    script>

    function 
    toggle5(showHideDivswitchImgTag) {
            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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •