Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Oct 2002
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    view the submenues

    Hi,

    I'm a newbie and I have a problem with a java script:
    I have downloaded a java script. It's a menue with submenues.
    There are two submenues but i need three of them.
    So, i have modified the code. Now I have three submenues but it doesn't function correctly.
    When I click on submenu1 I see submenue2 AND submenue3- that's the problem: only if I click on Menue2, Menue3 is to appear.

    The script:

    <STYLE type="text/css">
    ....
    </style>
    <script language="JavaScript" type="text/javascript">

    function b_clipTo(t,r,b,l,w){if(bw.ns4){this.css.clip.top=t;this.css.clip.right=r
    this.css.clip.bottom=b;this.css.clip.left=l
    }else{this.css.clip="rect("+t+","+r+","+b+","+l+")"; if(w){this.css.width=r; this.css.height=b}}}

    function SlideMenuInit(){
    oSlideMenu=new makeMenuObj('divSlideCont')
    oSlideMenu.moveIt(menux,menuy)
    oSlide=new Array()
    for(i=0;i<menus.length;i++){
    oSlide[i]=new makeMenuObj('divSlide'+i,'divSlideCont')
    oSlide[i].subs=menus[i].subs
    oSlide[i].sub=new Array()
    oSlide[i].moveIt(0,mainheight*i)
    oSlide[i].starty=oSlide[i].y
    if(bw.opera) oSlide[i].css.paddingLeft="10px"
    if(!menus[i].seperator) oSlide[i].bgImg(level0_regular)
    for(j=0;j<oSlide[i].subs;j++){
    oSlide[i].sub[j]=new makeMenuObj('divSlideSub'+i+"_"+j,'divSlideCont')
    oSlide[i].sub[j].moveIt(10,oSlide[i].y+subheight*j+between)
    oSlide[i].sub[j].starty=oSlide[i].sub[j].y
    oSlide[i][j]=new Array()
    oSlide[i][j].subs=menus[i][j].subs
    oSlide[i][j].sub=new Array()
    img=level1_round
    if(oSlide[i][j].subs!=0){
    if(j!=oSlide[i].subs-1) img=level1_sub
    else img=level1_sub_round
    oSlide[i].sub[j].css.color="white"
    }else{
    if(j!=oSlide[i].subs-1)img=level1_regular
    }
    oSlide[i].sub[j].origimg=img
    oSlide[i].sub[j].bgImg(img)
    for(a=0;a<oSlide[i][j].subs;a++){
    oSlide[i][j].sub[a]=new makeMenuObj('divSlideSub'+i+"_"+j+"_"+a,'divSlideCont')
    oSlide[i][j].sub[a].moveIt(20,oSlide[i].sub[j].y+subheight*a+between-2)
    oSlide[i][j].sub[a].starty=oSlide[i][j].sub[a].y
    oSlide[i][j][a]=new Array()
    oSlide[i][j][a].subs=menus[i][j][a].subs
    oSlide[i][j][a].sub=new Array()
    if(a!=oSlide[i][j].subs-1) img=level2_regular
    else img=level2_round
    oSlide[i][j].sub[a].origimg=img
    oSlide[i][j].sub[a].bgImg(img)
    }
    }
    }
    oSlideMenu.showIt()
    }
    //***Variables
    var active=-1;var going;var isthere; var sactive=-1; var sisthere=-1; var s2active=-1; var s2isthere=-1

    //***Switch menu function.
    function swmenu(num,snum,s2num){
    if(snum!=-1){
    if(oSlide[num][snum].subs==0) return
    }
    if(s2num!=-1){
    if(oSlide[num][snum][s2num].subs==0) return
    }
    if((num!=active || snum!=sactive || s2num!=s2active) && !going){going=true;isthere=0;sisthere=0;moveUp(num,snum,s2num)}
    }

    //***Moving the menus upward to their original position.
    function moveUp(num,snum){
    if(snum==-1){
    for(i=0;i<oSlide.length;i++){
    if(oSlide[i].y>oSlide[i].starty+pxspeed && active!=i) oSlide[i].moveBy(0,-pxspeed)
    else{if(active!=i) oSlide[i].moveIt(oSlide[i].x,oSlide[i].starty); isthere=i}
    }

    if(isthere<oSlide.length-1) setTimeout("moveUp("+num+","+snum+")",timspeed)
    else swmenu2(num,snum)
    }else{
    if(num==oSlide.length-1) isthere=num

    if(sactive!=-1){ //Is out!
    //Slide subs
    j=0
    for(i=sactive+1;i<oSlide[num].sub.length;i++){
    j++
    if(oSlide[num].sub[i].y>oSlide[num].sub[i].starty+pxspeed) oSlide[num].sub[i].moveBy(0,-pxspeed)
    else{oSlide[num].sub[i].moveIt(oSlide[num].sub[i].x,oSlide[num].sub[i].starty); sisthere=i}
    }

    //Slide main
    for(i=num+1;i<oSlide.length;i++){
    if(oSlide[i].y>oSlide[i].starty + oSlide[num].sub[sactive].y +subheight*j ) oSlide[i].moveBy(0,-pxspeed)
    else{oSlide[i].moveIt(oSlide[i].x,oSlide[i].starty + oSlide[num].sub[sactive].y +subheight*j ); isthere=i}
    }
    }else{ //Slide to the one clicked
    for(i=num+1;i<oSlide.length;i++){
    if(oSlide[i].y>oSlide[i].starty + snum*between+between) oSlide[i].moveBy(0,-pxspeed)
    else{oSlide[i].moveIt(oSlide[i].x,oSlide[i].starty + snum*between+between); isthere=i}
    }
    }
    if(isthere<oSlide.length-1 || (sactive!=-1 && sisthere<oSlide[num].sub.length-1 && sactive!=oSlide[num].sub.length-1)) setTimeout("moveUp("+num+","+snum+")",timspeed)
    else swmenu2(num,snum)
    }
    }

    //***Switch menu 2, stuff that happens before the menus are moved down again.

    function swmenu2(num,snum){
    isthere=0;
    sisthere=0;
    if(active>-1 && snum==-1){

    //Hiding submenus
    for(j=0;j<oSlide[active].subs;j++){oSlide[active].sub[j].hideIt()}
    oSlide[active].bgImg(level0_regular)
    oSlide[active].moveIt(0,oSlide[active].starty)
    }
    if(sactive>-1){

    //Hiding submenus
    for(j=0;j<oSlide[active][sactive].sub.length;j++){oSlide[active][sactive].sub[j].hideIt()}
    oSlide[active].sub[sactive].bgImg(oSlide[active].sub[sactive].origimg)
    oSlide[active].sub[sactive].moveIt(10,oSlide[active].sub[sactive].starty)

    //Move back to place
    for(i=sactive+1;i<oSlide[active].sub.length;i++){
    oSlide[active].sub[i].moveIt(oSlide[active].sub[i].x,oSlide[active].sub[i].starty)
    }
    }
    active=num

    //Showing submenus
    if(snum>-1){
    sactive=snum
    for(j=0;j<oSlide[num][snum].sub.length;j++){oSlide[num][snum].sub[j].showIt()}
    oSlide[num].sub[snum].moveBy(10,3)
    oSlide[num].sub[snum].bgImg(level1_round2)
    }else{
    sactive=-1
    for(j=0;j<oSlide[active].subs;j++){oSlide[active].sub[j].showIt()}
    oSlide[num].moveBy(10,3)
    oSlide[num].bgImg(level0_round)
    }
    if(num!=oSlide.length-1) moveDown(num,snum)
    else{
    isthere=num
    moveDown(num,snum)
    }
    }

    //***Moving the menus down
    function moveDown(num,snum){
    //if(num==oSlide.length-1) isthere=num
    for(i=num+1;i<oSlide.length;i++){
    if(snum==-1){
    if(oSlide[i].y<(oSlide[num].subs-1)*subheight+oSlide[i].starty+between-pxspeed) oSlide[i].moveBy(0,pxspeed)
    else{oSlide[i].moveIt(oSlide[i].x,(oSlide[num].subs-1)*subheight+oSlide[i].starty+between); isthere=i}
    }else{
    if(oSlide[i].y<(oSlide[num].subs-1)*subheight+oSlide[i].starty+between-pxspeed + (oSlide[num][snum].subs-1)*subheight+between) oSlide[i].moveBy(0,pxspeed)
    else{oSlide[i].moveIt(oSlide[i].x,(oSlide[num].subs-1)*subheight+oSlide[i].starty+between + (oSlide[num][snum].subs-1)*subheight+between); isthere=i}
    }
    }
    if(snum!=-1){
    for(i=snum+1;i<oSlide[num].sub.length;i++){
    if(oSlide[num].sub[i].y<(oSlide[num][snum].subs-1)*subheight+oSlide[num].sub[i].starty+between-pxspeed) oSlide[num].sub[i].moveBy(0,pxspeed)
    else{oSlide[num].sub[i].moveIt(oSlide[num].sub[i].x,(oSlide[num][snum].subs-1)*subheight+oSlide[num].sub[i].starty+between); sisthere=i}
    }
    }
    if(snum==-1){
    if(isthere<oSlide.length-1) setTimeout("moveDown("+num+","+snum+")",timspeed)
    else going=false
    }else{
    if(isthere<oSlide.length-1 || (sisthere<oSlide[num].sub.length-1 && snum!=oSlide[num].sub.length-1)) setTimeout("moveDown("+num+","+snum+")",timspeed)
    else going=false
    }
    }
    var test=0


    //***Functions to write out the layers...
    menus=new Array(); var a=0; var b=0; var c=0; var d=0
    function makeMenu(type,text,lnk,target,end){
    str=""; tg="";
    if(target) tg='target="'+target+'"'
    if(!lnk) lnk="#"

    if(a==0) str='<div id="divSlideCont">\n'
    if(type=="top"){
    menus[a]=new Array();
    if(text=="seperator"){
    str+='\t<div id="divSlide'+a+'" class="clSlide"></div>\n'
    menus[a].seperator=1
    }else{
    str+='\t<div id="divSlide'+a+'" class="clSlide"><a href="'+lnk+'" '+tg+' onclick="swmenu('+a+',-1,-1); if(bw.ie || bw.ns6) this.blur(); '
    if(lnk=="#") str+='return false'
    str+='" class="clSlideLinks"> '+text+'</a><br></div>\n'
    }
    menus[a].subs=0; a++; b=0
    }else if(type=="sub"){
    str+='\t\t<div id="divSlideSub'+(a-1)+'_'+(b)+'" class="clSlideSub"><a '+tg+' onclick="swmenu('+(a-1)+','+b+',-1); if(bw.ie || bw.ns6) this.blur(); '
    if(lnk=="#") str+='return false'
    str+='" href="'+lnk+'" class="clSlideSubLinks"> '+text+'</a><br></div>\n'
    b++; menus[a-1].subs=b; menus[a-1][b-1]=new Array(); c=0; menus[a-1][b-1].subs=0
    }else if(type=="sub2"){
    str+='\t\t<div id="divSlideSub'+(a-1)+'_'+(b-1)+'_'+c+'" class="clSlideSub2"><a '+tg+' href="'+lnk+'" class="clSlideSub2Links"> '+text+'</a><br></div>\n'
    c++; menus[a-1][b-1].subs=c; menus[a-1][b-1][c-1]=new Array(); d=0; menus[a-1][b-1][c-1].subs=0
    }else if(type=="sub3"){
    str+='\t\t<div id="divSlideSub'+(a-1)+'_'+(b-1)+'_'+c+'" class="clSlideSub3"><a '+tg+' href="'+lnk+'" class="clSlideSub3Links"> '+text+'</a><br></div>\n'
    c++; menus[a-1][b-1].subs=c; menus[a-1][b-1][c-1]=new Array(); d=0; menus[a-1][b-1][c-1].subs=0
    }
    if(end) str+="</div>"
    document.write(str)
    }
    function preLoadBackgrounds(){
    for(i=0;i<arguments.length;i++){
    this[i]=new Image()
    this[i].src=arguments[i]
    }
    return this
    }
    </script>
    <base target="Hauptframe">
    </head>

    <body>
    <script>

    between=28 //The pixel between the menus and the submenus
    mainheight=32 //The height of the mainmenus
    subheight=31 //The height of the submenus
    pxspeed=23 //The pixel speed of the animation
    timspeed=30 //The timer speed of the animation
    menuy=15 //The top placement of the menu.
    menux=0 //The left placement of the menu

    //Images - Play with these
    ....

    preLoadBackgrounds
    ...

    makeMenu('top','Einführung')
    makeMenu('sub','1.1 Dies','test.htm','Hauptframe')
    makeMenu('sub2','1.1 Das','test.htm','Hauptframe')
    makeMenu('sub3','1.1 Blabla','test.htm','Hauptframe')

    Can someone tell me, which place I forgot in the code, and/or can someone edit the code in that the desired result is obtained? Thank you!

    Stephanie

  • #2
    WA
    WA is offline
    Administrator
    Join Date
    Mar 2002
    Posts
    2,596
    Thanks
    2
    Thanked 19 Times in 18 Posts
    Hi Sessai:
    We cannot support individual scripts, especially one as complex as this one. Your best chance lies in trying to contact the author directly for support on his creation.
    - George
    - JavaScript Kit- JavaScript tutorials and 400+ scripts!
    - JavaScript Reference- JavaScript reference you can relate to.

  • #3
    Regular Coder bacterozoid's Avatar
    Join Date
    Jun 2002
    Location
    USA
    Posts
    490
    Thanks
    24
    Thanked 35 Times in 35 Posts
    Just go through your code and make sure you have everything you modified for your third menu to say '3' or whatever it would need to say. If that fails, might just try resetting the script and starting over with your modifications. If that fails, then like WA instructed, see the author for help.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •