SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Philadelphia
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What won't this code work?

    This is weird.

    I have a menu with transparent gifs that you rollover. When you rollover one of three transparent gifs, the corresponding "menu" appears, which is really just a php include of a table (concatenated line by line since JavaScript does not seem to support multi-line strings) with images in it.

    The problem is that with all 3 functions in here, when you rollover, i get javascript errors and the functions are not even called. With only ONE function, it works.


    Very very simple Javascript code here:

    Code JavaScript:
    <script type='text/javascript'> 
    function showGameMenu(){
     
    var mydiv = document.getElementById('row4');
    mydiv.innerHTML = <?php include("gamemenu.php");?>; 
     
     }
     
     function showWebMenu(){
     
    var mydiv2 = document.getElementById('row4');
    mydiv2.innerHTML = <?php include("webmenu.php");?>; 
     
     }
     
    function showClassMenu(){
     
    var mydiv3 = document.getElementById('row4');
    mydiv3.innerHTML = <?php include("classmenu.php");?>; 
     }
    </script>

    and here is how I call the code:


    Code HTML4Strict:
    <table border="0" cellpadding="0" cellspacing="0">
    	<tr>
    	<td><a href="#" onmouseover="showGameMenu()"><img align="left" src="index2010slices/spacer.gif" width="200" height="50" /></a></td>
     
    	<td><a href="#" onmouseover="showWebMenu()"><img align="left" src="index2010slices/spacer.gif" width="217" height="50" /></a></td>
     
    	<td><a href="#" onmouseover="showClassMenu()"><img align="left" src="index2010slices/spacer.gif" width="200" height="50" /></a></td>
    	</tr>
    	</table>

    Nothing works. Yet if I delete the second two functions, leaving ONLY the showGameMenu function, then it works.

    Here is the code for one of the the php includes that is being "popped" into the div. (they are all pretty much identical):

    Code HTML4Strict:
    "<table width='700' border='0'>"+
      "<tr>"+
        "<td><a href='#'><img src='menuslices/gameMenu_r1_c1.jpg' alt='game_design_classes' width='227' height='49'></a></td>"+
        "<td><a href='#'><img src='menuslices/gameMenu_r2_c3.jpg' alt='games_for_sale' width='210' height='49'></a></td>"+
        "<td><a href='#'><img src='menuslices/gameMenu_r1_c3.jpg' alt='free_game_updates' width='208' height='49'></a></td>"+
        "<td><a href='#'><img src='menuslices/gameMenu_r1_c4.jpg' alt='sponsor_a_game' width='213' height='49'></a></td>"+
      "</tr>"+
    "</table>"

    and finally, here is the url where its all happening:

    www.mediabreeze.com/index.php?live=true

    thanks !

  2. #2
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Philadelphia
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What is ever more weird are the JavaScript console errors:

    Uncaught SyntaxError: Unexpected number
    index.php:113Uncaught ReferenceError: showGameMenu is not defined
    index.php:115Uncaught ReferenceError: showWebMenu is not defined
    index.php:117Uncaught ReferenceError: showClassMenu is not defined

  3. #3
    SitePoint Addict
    Join Date
    Dec 2002
    Location
    Philadelphia
    Posts
    299
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, my code was correct. I solved it.... there were extra carriage returns in one of the php files causing the multi-line "concatenation" trick to fail. It works now.


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
  •