SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need some javascript help

    Code:
    <script>
    function clickPost(el){
    	var im=el.parentNode.style.backgroundImage;
    	var sp0=im.split("/");
    	var sp1=sp0[sp0.length-1].split(".");
    	document.getElementById("formInp").value=sp1[0];
    	document.F.submit();
    }
    </script>
    Code:
    <div class="thumb" style="background-image: url('images/1.jpg');"><a href='javascript:void(0)' onclick='clickPost(this)'>
    This code snags the number from the background-image file, I changed my code around and I believe I need to go to a childnode now but am having issues figuring it out. Thanks

    Code:
    <div id="container">
    <a href='javascript:void(0)' onclick='clickPost(this)'><div class="overlay"></div>
    <div class="image"><img src="images/2.jpg" /></a></div>
    </div>

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which element has the background image?
    Tab-indentation is a crime against humanity.

  3. #3
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The very bottom code is what I am using now

    Code:
    <div id="container">
    <a href='javascript:void(0)' onclick='clickPost(this)'><div class="overlay"></div>
    <div class="image"><img src="images/2.jpg" /></a></div>
    </div>
    Whats on top in my first post is what was used before


Bookmarks

Posting Permissions

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