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<br>Option 2<br>Option 3<br>";

What I need to change is

Option 1<br>Option 2<br>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<br>Option 2<br>Option 3<br>";

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

"<table border="0" cellpadding="0" style="border-collapse: collapse" width="744">
<tr>
<td bgcolor="#E7F0F5">
<p align="center"><font face="Arial" size="5">


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:

<tr>

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:
"<table border="0" cellpadding="0" style="border-collapse: collapse" width="744">
<tr>
<td bgcolor="#E7F0F5">
<p align="center"><font face="Arial" size="5">


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:
<!--
Collapsible Menu Script.
Created by Kyle Edwards.
Please keep this notice intact.
-->
<!--
Below is the code for the hyperlinks that expand and collapse the menusYou need to do the following for each menu:
1. Create hyperlink code that looks like this:
<
a href="#" onclick="collapse_menu(menu1, 0)">The value of the link goes here.</a><br>
NoteChange menu1 to the name of the menu, and change 0 to the number of the menu.
Note0 is the number of the FIRST menu.
2. After each hyperlinktype in code that looks like this:
<
span id="menu1"></span>
NoteChange "menu1" to the name of the menu.
3. Follow the instructions inside the <scripttagsThey follow //'s.
-->
<
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 <br> tag.
//Note: If you want to indent the options, type &nbsp; for each space of indentation.
//and a </blockquote> tag at the end.
//Example: "&nbsp;&nbsp;Option 1<br>&nbsp;&nbsp;Option 2<br>"
//This puts two spaces at the beginning of each option.

menu_code[0]="Option 1<br>Option 2<br>Option 3<br>";
menu_code[1]="Option 1<br>Option 2<br>Option 3<br>";

//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 1</a><br>
<
span id="menu1"></span>
<
a href="#" onclick="javascript: collapse_menu(document.getElementById('menu2'), 1); return false;">Menu 2</a><br>
<
span id="menu2"></span>

Login

Who's Online

185 user(s) are online (121 user(s) are browsing Support Forums)


Members: 0


Guests: 185


more...

Donat-O-Meter

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

Latest GitHub Commits