1
ardenb
Javascript collapsible menu in Custom block
  • 2009/10/24 16:19

  • ardenb

  • Just popping in

  • Posts: 2

  • Since: 2009/10/24


This is the information for the script I'm trying to use:
//Collapsible Menu Script.
//Created by Kyle Edwards.

I was able to take this code and put it in the body of my webpage. It works fine as is. But when I try to edit it, I get a script error message. Here is the code I'm trying to edit:

menu_code[0]="Option 1
Option 2
Option 3
";

What I need to change is

Option 1
Option 2
Option 3

to put a table with form properties inside it. But when I copy the table, this is when I get an error message. Is there a way to do this?

2
ghia
Re: Javascript collapsible menu in Custom block
  • 2009/10/24 17:03

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


ardenb, welcome to the XOOPS forum!

What was the error message you get during editing?

3
ardenb
Re: Javascript collapsible menu in Custom block
  • 2009/10/25 16:11

  • ardenb

  • Just popping in

  • Posts: 2

  • Since: 2009/10/24


Here is the original code from the script:

menu_code[0]="Option 1
Option 2
Option 3
";

Here is the beginning of the code I'm putting in after =:

"



THANK YOU for your reply!





4
ghia
Re: Javascript collapsible menu in Custom block
  • 2009/10/25 22:26

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Quote:
"




Using FrontPage, I click on Preview, and this is the error meesage I get:

An error has occurred in the script on this page.
Line: 55
Char: 30
Error: Expected ';'
Code: 0

When I look on line 55, there is:






You may not use " for delemiting the string and then use it inside the string itself. There it needs to be escaped or use '.

Try it with this:



<
script  type="text/javascript" >
//Collapsible Menu Script.
//Created by Kyle Edwards.
//Please keep this notice intact.

//This defines the arrays that contain info about the menus. Do NOT edit.
var on_off=new Array();
var 
menu_code=new Array();

//Below, define number_of_menus. It should be equal to the number of menus you have.
number_of_menus=2;

//Here we define the code for the menus. Inside the quotation marks, type in the value of each option.
//Note: After each option, you need to put a 
 tag.
//Note: If you want to indent the options, type   for each space of indentation.
//and a  tag at the end.
//Example: "  Option 1
  Option 2
"
//This puts two spaces at the beginning of each option.

menu_code[0]="Option 1
Option 2
Option 3
"
;
menu_code[1]="Option 1
Option 2
Option 3
"
;

//Everything below this notice is the code that expands and collapses the menus. Do NOT edit.
for (loop=0loop<number_of_menusloop++){
 
on_off[loop]=0;
}

function 
collapse_menu(menu_idmenu_number){
  if (
on_off[menu_number]==0){
    
menu_id.innerHTML=menu_code[menu_number];
    
on_off[menu_number]=1;
  }else{
    
menu_id.innerHTML="";
    
on_off[menu_number]=0;
  }
}
script>
<
p>
<
a href="#" onclick="javascript: collapse_menu(document.getElementById('menu1'), 0); return false;">Menu 1a><br>
<
span id="menu1">span>
<
a href="#" onclick="javascript: collapse_menu(document.getElementById('menu2'), 1); return false;">Menu 2a><br>
<
span id="menu2">span>

Login

Who's Online

416 user(s) are online (55 user(s) are browsing Support Forums)


Members: 0


Guests: 416


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits