SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot lighter's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript cant work after .html becomes .php

    I need help!

    I have this random table background javascript that cant work after i change the file format from .html to .php.

    This is the source code

    Code:
    <TABLE ID='tableID' cellSpacing=0 cellPadding=0 width="100%" border=0 background="images/bg1.jpg">
      <TBODY> 
      <TR> 
        <TD width=492 height="150" background="images/bg1.jpg"> 
          <script type="text/javascript">
    var bg_list = new Array("images/bg1.jpg", "images/bg2.jpg", "images/bg3.jpg", "images/bg4.jpg", "images/bg5.jpg");
    var rand_bg = bg_list[ Math.floor( Math.random() * bg_list.length ) ]; 
    if (document.getElementById)
      document.getElementById('tableID').style.backgroundImage = "url("+rand_bg+")";
    </script>
    The javascript is used at this page, http://www.plecofanatics.com

    Can anyone tell me whats wrong here?
    PlecoFanatics.com - Pleco, Fish, Aquariums, Aquatic Forums.

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I checked the source code directly from your site and it looks like you are missing some semicolons in your JavaScript functions starting at line 496.

    Hope this helps.
    -: Arnold Nicolas :-
    www.filgoods.com

  3. #3
    SitePoint Zealot lighter's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Arnold, thanks for helping.

    Is it possible that you highlight specifically which line has those problems and how do i ammend that? I'm a retard at javascripts!

    The only javascript that is having problem is the random table background image ratator, the rest are fine though.
    PlecoFanatics.com - Pleco, Fish, Aquariums, Aquatic Forums.

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post your code and I"ll be able to hightlight the section you need to fix.
    -: Arnold Nicolas :-
    www.filgoods.com

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put the ID on the TD, not the TABLE. You are putting the initial (default) bg image on the TD so changing the table bg has no visible effect - it is behind the TD.

    btw... that's an unusual fish!

  6. #6
    SitePoint Zealot lighter's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys! It works now! Thanks for those comments!!!
    PlecoFanatics.com - Pleco, Fish, Aquariums, Aquatic Forums.


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
  •