473,403 Members | 2,354 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

submenu does'nt appears

Hello,
I'm trying to convert an existing menu and submenus in javascript by using DOM methods. The previous one uses only document.write.

I do not manage to show the sub-menus with the onmouseover event.

see lines 18 & 19:


Expand|Select|Wrap|Line Numbers
  1. function affiche(id) {
  2.  
  3. var d = document.getElementById(id);
  4.     for (var i = 1; i<=9; i++) {
  5.         if (document.getElementById('sousmenu'+i)) {document.getElementById('sousmenu'+i).style.display='none';}
  6.     }
  7. if (d) {d.style.display='block';}
  8. }
  9. // <!-- bibliothèques -->
  10. alert('début biblio');
  11. div_biblio = document.createElement('div');
  12. div_biblio.id = 'bibliotheques';
  13. div_biblio.className = 'menu';
  14. lien = document.createElement('a');
  15. lien.href = '#';
  16. lien.textContent = 'Bibliotheques';
  17. div_biblio.appendChild(lien);
  18. div_biblio.onmouseover = affiche('sousmenu3');
  19. div_biblio.onmouseout = affiche();
  20. alert('fin biblio');
  21.  
  22. alert('début biblio_sousmenu');
  23. div_biblio_sousmenu = document.createElement('div');
  24. div_biblio_sousmenu.id = 'sousmenu3';
  25. div_biblio_sousmenu.className = 'sousmenu';
  26. div_biblio_sousmenu.style.display = 'none';
  27. div_biblio_sousmenu.onmouseout = affiche();
  28. div_biblio.appendChild(div_biblio_sousmenu);
  29. alert('fin biblio_sousmenu');
  30.  
  31. alert('début biblio_sousmenu_1');
  32. div_biblio_sousmenu_1 = document.createElement('div');
  33. lien = document.createElement('a');
  34. lien.href = 'http://homeusers.brutele.be/metalcat/bibliotheque-1.htm';
  35. lien.textContent = 'Phase 1';
  36. div_biblio_sousmenu.appendChild(lien);
  37. div_biblio_sousmenu.appendChild(div_biblio_sousmenu_1);
  38. alert('fin biblio_sousmenu_1');
  39.  
  40. alert('début biblio_sousmenu_2');
  41. div_biblio_sousmenu_2 = document.createElement('div');
  42. lien = document.createElement('a');
  43. lien.href = 'http://homeusers.brutele.be/metalcat/bibliotheque-2.htm';
  44. lien.textContent = 'Phase 2';
  45. div_biblio_sousmenu.appendChild(lien);
  46. div_biblio_sousmenu.appendChild(div_biblio_sousmenu_2);
  47. alert('fin biblio_sousmenu_2');
  48.  
  49. div_menu_principal.appendChild(div_biblio);
  50.  
Here the original :
Expand|Select|Wrap|Line Numbers
  1. //document.write( " <div class='menu' id=\"bibliotheques\"onmouseover=\"affiche('sousmenu3');\" onmouseout=\"affiche();\">" );
  2. //document.write( " <a href=\"#\" onclick=\"window.location.reload()\">Biblioth&egrave;ques</a>" );
  3. //document.write( "  <div class=\"sousmenu\" id=\"sousmenu3\" style=\"display:none\" onmouseout=\"affiche();\" >" );
  4. //document.write( "   <div><a href=\"http://homeusers.brutele.be/metalcat/bibliotheque-1.htm\">Phase 1</a></div>" );
  5. //document.write( "   <div><a href=\"http://homeusers.brutele.be/metalcat/bibliotheque-2.htm\">Phase 2</a></div>" );
  6.  
Thank you for help. Sorry for my English.

Regards
Guy Janssens
Brussels
May 28 '16 #1
1 1263
div_biblio.onmouseover = function() {affiche('sousmenu3')};
div_biblio.onmouseout = function() {affiche()};
May 29 '16 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Tom | last post by:
This is for AccessXP I goto View - Toolbars - Customize and am able to brong up the Customize dialog for my custom menu. I can click on a menu item to select it and the blackbox appears around...
1
by: PAUL MITCHELL | last post by:
Hello, bit of strange one this, I have a VB .net application that has Sub Main() as its startup procedure, this then creates and shows a form. Up till now when I pressed F5 the form would duly...
0
by: jeff.perreault | last post by:
I have a problem with a skmMenu submenu and I think it has to do with an IIS Setting. I have the same website set up on two servers - One is MS 2003, the other is MS 2003 R2 If I load the web...
5
by: Jonathan | last post by:
Hello All, I am in the process of creating a 2/3 level collapsible/exspanible menu (called "nav") where users can click on a category and have the submenus appear beneath it and so on (allow...
0
Denburt
by: Denburt | last post by:
This code is for a Toggle Button layout on a form, with this code you can set a number of toggle buttons visible and have multiple submenus that will stay hidden when not in use. My main menu is set...
2
by: az538 | last post by:
Hello All, I am having a problem with my menu and submenu system. It works like a champ in IE6 and Firefox but IE7 renders the submenus in incorrect positions on the page. Also, the menu system...
1
by: bhosalevivek | last post by:
I did this code from Dynamic Drive DHTML. it's working properly, but now I need submenu for "Submenu 1.2", means when I take mouse on "Submenu 1.2" I need to display "Submenu 1.2.1". I try to do...
1
oll3i
by: oll3i | last post by:
i have written css tab menu but my links in submenu inherit the style of a href in main menu (#menu ul li a)? when i hover over the links in submenu they do change as i want them to change they...
5
by: remon87 | last post by:
I need some help. I have javasript that creates the submenu but it works if I have a text with css. I need it to do the same with a roll over images. so when I click on the image the submenu...
5
by: leesyaa | last post by:
hello, I have this problem on making a sub-menu in my navigation bar. it seems to be overlapped. how can I prevent this? I can't work out how to make the sub-menu open when you hover on the main...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.