I am a Javascript newb, and I am haveing some trouble with my arguments.

function openMenu(tableName)	{
document.getElementById(tableName).style.visibility="visible";
}

This is the code i have, and it is working perfectly on the different menus at the top of my screen. The problem i have is with my table IDs, i get the ids from a database using php, and one of them has a space in the centre, so that one doesnt work. This is my php if anything can be changed in either language i would be grateful for any help.

while($row=mysql_fetch_array($query))
	{
	echo '
	<td class="bar" onmouseover=Javascript:openMenu("' . $row['category'] . '")
	onmouseout=Javascript:closeMenu("' . $row['category'] . '")>
	<a href="category.php?cat=' . $row['category'] . '" class="top_menu"><div>' . $row['category'] . '</div></a><div>';

I am a Javascript newb, and I am haveing some trouble with my arguments.

while($row=mysql_fetch_array($query))
	{
	echo '
	<td class="bar" onmouseover=Javascript:openMenu("' . $row['category'] . '")
	onmouseout=Javascript:closeMenu("' . $row['category'] . '")>
	<a href="category.php?cat=' . $row['category'] . '" class="top_menu"><div>' . $row['category'] . '</div></a><div>';

Based on the W3C standards you must encapsulate attribute values in quotes ie, name="hello" is right, name=hello is wrong.
So your echo is breaking the script.

echo 
"<td class='bar' onmouseover='openMenu(\"".$row['category']."\");' 
                 onmouseout=''closeMenu(\"".$row['category']."\");' >
   <a href='category.php?cat=".$row['category']."' class='top_menu'><div>".$row['category']."</div></a><div>\n";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.