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 11 of 11
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I need another pair of eyes, please...

    Why is the following code giving me a nebulous syntax error?

    Code:
    if (input == 'top') 
    	{
    	document.getElementById('menu').innerHTML = '<div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\';" onmouseout="this.style.color=\'#000000\';" onclick="menu(\'add\');">Add</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\';" onmouseout="this.style.color=\'#000000\';" onclick="menu(\'edit\');">Edit</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'view\');">View</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'search\');">Search</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'report\');">Report</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'config\');">Configure</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'util\');">Utilities</div>';
    	}

  • #2
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    We need more context... What's "input"?

    I don't see any syntax errors on that.

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    More context it is...

    Code:
    <html>
    <head>
    <title>AWDacious Documentation!</title>
    <link rel="stylesheet" type="text/css" href="main.css">
    
    <script>
    function menu(input)
    {
    if (input == 'top') 
    	{
    	document.getElementById('menu').innerHTML = '<div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\';" onmouseout="this.style.color=\'#000000\';" onclick="menu(\'add\');">Add</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\';" onmouseout="this.style.color=\'#000000\';" onclick="menu(\'edit\');">Edit</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'view\');">View</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'search\');">Search</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'report\');">Report</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'config\');">Configure</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\'; onmouseout="this.style.color=\'#000000\';" onclick="menu(\'util\');">Utilities</div>';
    	}
    
    if (input == 'add') 
    	{
    	document.getElementById('maindiv').innerHTML = '<iframe name="main" width="100%" height="33%" frameborder=0 src="add.php">';
    	}
    	
    if (input == 'edit') 
    	{
    	document.getElementById('maindiv').innerHTML = '<iframe name="main" width="100%" height="33%" frameborder=0 src="edit.php">';
    	}
    	
    if (input == 'view') 
    	{
    	document.getElementById('maindiv').innerHTML = '<iframe name="main" width="100%" height="33%" frameborder=0 src="view.php">';
    	}
    	
    if (input == 'search') 
    	{
    	document.getElementById('maindiv').innerHTML = '<iframe name="main" width="100%" height="33%" frameborder=0 src="search.php">';
    	}
    	
    if (input == 'report') 
    	{
    	document.getElementById('menu').innerHTML = '<div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\';" onmouseout="this.style.color=\'#000000\';" onclick="menu(\'full\');">Full Report</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\';" onmouseout="this.style.color=\'#000000\';" onclick="menu(\'late\');">Late Report</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\';" onmouseout="this.style.color=\'#000000\';" onclick="menu(\'graph\');">Graphical Report</div><div id="menu_item" style="cursor:hand;" onmouseover="this.style.color=\'#3366FF\';" onmouseout="this.style.color=\'#000000\';" onclick="menu(\'top\');">Main Menu</div>';
    	}
    	
    if (input == 'full') 
    	{
    	document.getElementById('maindiv').innerHTML = '<iframe name="main" width="100%" height="33%" frameborder=0 src="full_report.php">';
    	}
    	
    if (input == 'late') 
    	{
    	document.getElementById('maindiv').innerHTML = '<iframe name="main" width="100%" height="33%" frameborder=0 src="late_report.php">';
    	}
    	
    if (input == 'graph') 
    	{
    	document.getElementById('maindiv').innerHTML = '<iframe name="main" width="100%" height="33%" frameborder=0 src="graph_report.php">';
    	}
    }
    </script>
    
    </head>
    <body>
    
    <center><table></center>
    <tr>
    <td><image src="banner.jpg"></td>
    <td align="center" valign="top"><image src="title.jpg">
    <div id="menu">
    <div id="menu_item" style="cursor:hand;" onmouseover="this.style.color='#3366FF';" onmouseout="this.style.color='#000000';" onclick="menu('add');">Add</div>
    <div id="menu_item" style="cursor:hand;" onmouseover="this.style.color='#3366FF';" onmouseout="this.style.color='#000000';" onclick="menu('edit');">Edit</div>
    <div id="menu_item" style="cursor:hand;" onmouseover="this.style.color='#3366FF';" onmouseout="this.style.color='#000000';" onclick="menu('view');">View</div>
    <div id="menu_item" style="cursor:hand;" onmouseover="this.style.color='#3366FF';" onmouseout="this.style.color='#000000';" onclick="menu('search');">Search</div>
    <div id="menu_item" style="cursor:hand;" onmouseover="this.style.color='#3366FF';" onmouseout="this.style.color='#000000';" onclick="menu('report');">Report</div>
    <div id="menu_item" style="cursor:hand;" onmouseover="this.style.color='#3366FF';" onmouseout="this.style.color='#000000';" onclick="menu('config');">Configure</div>
    <div id="menu_item" style="cursor:hand;" onmouseover="this.style.color='#3366FF';" onmouseout="this.style.color='#000000';" onclick="menu('util');">Utilities</div>
    </div>
    </td></tr></table></center>
    
    <br><br>
    
    <div id="maindiv"></div>
    
    </body>
    </html>

  • #4
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Code:
    onmouseover="this.style.color=\'#3366FF\';"
    Last double-quote. You need to rethink the way you're doing things, that's a very long line.

  • #5
    New Coder
    Join Date
    May 2004
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry I'm dense... I don't see what's wrong with that double quote.

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Another thing: The character sequence </ may not appear inside a script element in an HTML document (it may appear in a .js document, though). You should escape it as <\/.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #7
    New Coder
    Join Date
    May 2004
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well, that's a good point. thanks man. I tried it, but I'm still having the issue...

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think the "rethink this" ought to be examined a bit more, after all what you're showing is simply a list of links but you're using DIV tags instead of A tags for your anchors. Some simple CSS rules to cover the color change on hover and the code being written to the "menu" will be a lot shorter.

    Code:
    #menu a
        {
         color:#000000;
        }
    #menu a:hover
        {
         color:#3366ff;
        }
    You also name a number of items with the same ID which is illegal html. Only one element on your page should have the ID of "menu_item". If you want to apply additional CSS rules to all menu items then that should be a class name
    or those rules should be applied much as I showed above.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #9
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by questor
    Sorry I'm dense... I don't see what's wrong with that double quote.
    Your code doesn't have it.

  • #10
    New Coder
    Join Date
    May 2004
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Aha, finally I see it. Yeah, I put the double quotes in there and it's golden. Thanks guys, and thanks for the fine suggestion with css and all that. I'm kinda tired of a style sheets. No real reason. It works. K thanks folks.

  • #11
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh, I see. There's no syntax error in the actual code there, but there is in the code that you document.write


  •  

    Posting Permissions

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