Mongospliff: JavaScript Menu?

Beitrag lesen

Hallo an euch!!

ich habe ein Problem mit Javascript und CSS. ich möcht mir mit Javascript ein Menu mit Untermenu erstellen wobei das Menu mit css-stylesheet formatiert ist.

Wenn ich das erstemal auf einen der Links clicke öffnet sich das Untermenu, aber wenn ich dann ein zweites mal auf einen anderen Link clicken möchte funktioniert das script nicht mehr.

Ich weiss das der body nach dem ersten click überschrieben wird doch wie schreib ich das scirpt so dass es immer wieder vorhanden ist????

[code]

/ JavaScript Document

var testing = 0;

function checklink(testing){

moreLinks(testing);                         //alert(testing);

}

function moreLinks(testing){

document.write('<link href="css_for%20csstest1.css" rel="stylesheet" type="text/css">');                                 document.write('<body>');                                 document.write('<div id="frame_left">');                                 document.write('<h3>:: MENU</h3>');

//-- 1. Link                                         document.write('<div id="sectionLinks">');                                                 document.write('<a href="#" onClick="checklink(1)">:: LINKS</a>');                                         document.write('</div>');

if (testing == 1){                                                         document.write('<div id="sectionLinks2">');                                                                         document.write('<a href="index.htm">... weiter LINKS</a>');                                                                         document.write('<a href="#">... weiter LINKS</a>');                                                                         document.write('<a href="#">... weiter LINKS</a>');                                                         document.write('</div>');                                                 }

//-- 2. Link                                         document.write('<div id="sectionLinks">');                                                 document.write('<a href="#" onClick="checklink(2)">:: LINKS</a>');                                         document.write('</div>');

if (testing == 2){                                                         document.write('<div id="sectionLinks2">');                                                                         document.write('<a href="#">... weiter LINKS</a>');                                                                         document.write('<a href="#">... weiter LINKS</a>');                                                                         document.write('<a href="#">... weiter LINKS</a>');                                                         document.write('</div>');                                                 }

//-- 3. Link                                         document.write('<div id="sectionLinks">');                                                 document.write('<a href="#" onClick="checklink(3)">:: LINKS</a>');                                         document.write('</div>');

//-- 4. Link                                         document.write('<div id="sectionLinks">');                                                 document.write('<a href="#" onClick="checklink(4)">:: LINKS</a>');                                         document.write('</div>');

document.write('</div>');                                 document.write('</body>');                                 document.write(testing);                         }

[/code]

Danke im voraus

MFG

Mongospliff