/    Sign up×
Community /Pin to ProfileBookmark

I’m almost there PHP/Javascript menu

I am making a dynamic vertical drop down menu. Is there anyone out there who can tell me whats wrong with this code. I would be like…..thanks.

[code=php]
<html>

<head>

<title>Drop down menu</title>

<style text=”text/css”>

.display_none {display: none; }
</style>

<script type=”text/javascript”>

function showProduct() {
var els=document.getElementsByName(arguments[0]);
for(var i=0,l=els.length;i<l;i++){
els[i].style.display = “block”;
}
}

function hideProduct() {
var els=document.getElementsByName(arguments[0]);
for(var i=0,l=els.length;i<l;i++){
els[i].style.display = “none”;
}
}

</script>

</head>

<body>

<?PHP

$category=mysql_query(“SELECT * from products order by category, product ASC”);
$cnum=mysql_num_rows($category);
echo mysql_error();

echo “<ul>n”;

$count=1;
while($a=mysql_fetch_array($category)) {

if($a[category] != $lastcategory) {
$label=substr($a[category], 0, 2);
echo “<li><a href=”#” onMouseOver=”showProduct(‘p_$label’);” onMouseOut=”hideProduct(‘p_$label’);”>$a[category]</a></li>n”;
$lastcategory=$a[category];
}

$label=substr($a[category], 0, 2);
echo “<ul name=”p_$label” class=”display_none”><li>$a[product]</li></ul>n”;

$count++;
}

echo “</ul>n”;

?>
</body>

</html>
[/code]

Thanks,
matt
[url]www.maddDidley.com[/url]

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @madddidley spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...