...

View Full Version : I need another pair of eyes, please...



questor
11-03-2004, 04:13 AM
Why is the following code giving me a nebulous syntax error?



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>';
}

AaronW
11-03-2004, 04:27 AM
We need more context... What's "input"?

I don't see any syntax errors on that.

questor
11-03-2004, 04:28 AM
More context it is...



<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>

hemebond
11-03-2004, 04:41 AM
onmouseover="this.style.color=\'#3366FF\';"Last double-quote. You need to rethink the way you're doing things, that's a very long line.

questor
11-03-2004, 04:46 AM
Sorry I'm dense... I don't see what's wrong with that double quote.

liorean
11-03-2004, 04:48 AM
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 <\/.

questor
11-03-2004, 04:54 AM
well, that's a good point. thanks man. I tried it, but I'm still having the issue...

Roy Sinclair
11-03-2004, 08:12 PM
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.



#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.

hemebond
11-03-2004, 10:19 PM
Sorry I'm dense... I don't see what's wrong with that double quote.Your code doesn't have it.

questor
11-04-2004, 03:43 AM
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.

AaronW
11-04-2004, 03:14 PM
Oh, I see. There's no syntax error in the actual code there, but there is in the code that you document.write :o



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum