PDA

View Full Version : array and function help


bookworm
11-18-2003, 03:44 PM
im making this funkymenu thing and i have it access an array for each link. but when i run it, i get an object expected error. I have the code on my site

bookworm.buildtolearn.com

heres my code pasted. Its says there are errors at line 6, 43 and 44 but i cant figure out what they are.

<head>
<script type="text/javascript">
function funkymenu(x)
{
var funkmen= new Array(7)
funkmen[1]="<a href="h;ttp://bookworm.buildtolearn.com">Home</a>"
funkmen[2]="Fun Links</br>Webhelp Links</br>Miscellaneous Links"
funkmen[3]="'
funkmen[4]=""
funkmen[5]=""
funkmen[6]=""
funkmen[7]=""

var divname= new Array(7);
divname[1]="htmloutput1"
divname[2]="htmloutput2"
divname[3]=""
divname[4]=""
divname[5]=""
divname[6]=""
divname[7]=""
document.getElementById("divname[x]").innerHTML=funkmen[x];
}
function clearfunkymenu(x)
{
var clearmen = new Array;
clearmen[1]="htmloutput1"
clearmen[2]="htmloutput2"
clearmen[3]=""
clearmen[4]=""
clearmen[5]=""
clearmen[6]=""
clearmen[7]=""
document.getElementById("clearmen[x]").innerHTML="";
}
</script>
</head>
<body>
<table width="100%" height="300%" rows="2" cols="2" border="1" cellspacing="0">
<tr height="10%"><td colspan="2">d</td></tr>
<tr height="490%" width="10%"><td valign="top">
<table rows="7" width="100%">
<tr><td><a href="http://bookworm.buildtolearn.com" onMouseOver="funkymen(1)" onMouseOut="clearmen(1)">Home</a><div id="htmloutput1"></div></td></tr>
<tr><td><a href="http://bookworm.buildtolearn.com/Pages/Links.html" onMouseOver="funkymen(2)" onMouseOut="clearmen(2)">Links</a><div id="htmloutput2"></div></td></tr>
</table>
</td>
<td width="80%">
<iframe scrolling="no" name="main" width="100%" height="100%" src="http://bookworm.hyperboards.com">
</td></tr></table>

bookworm
11-18-2003, 04:08 PM
okay, to help you people help me. heres the lines that it says there is an error in


<a href="http://bookworm.buildtolearn.com" onMouseOver="funkymen(1)" onMouseOut="clearmen(1)">Home</a><div id="htmloutput1"></div>

<a href="http://bookworm.buildtolearn.com/Pages/Links.html" onMouseOver="funkymen(2)" onMouseOut="clearmen(2)">Links</a><div id="htmloutput2"></div>

adios
11-18-2003, 04:25 PM
Just curious: have you been drinking? :D

...onMouseOver="funkymen(1)" onMouseOut="clearmen(1)">

function funkymenu(x)
{
var funkmen= new Array(7)

function clearfunkymenu(x)
{
var clearmen = new Array;

document.getElementById("divname[x]").innerHTML=funkmen[x];

This looks - forgive me - like one of those 'I think I'll just skip those first seven chapters of that JS book' situations. At the least, try giving some of your variables the same names as you intend to refer to them by...

bookworm
11-18-2003, 04:31 PM
ohhhh?? smacks head. Boy do i feel like an idiot.

bookworm
11-18-2003, 04:40 PM
okay, i got it now. hehe, the mistakes you make at nine in the morning.

adios
11-18-2003, 04:44 PM
Try smacking your head again. Works for me. :thumbsup:

btw 'Object expected' invariably means 'I can't find that function, and it's your fault.'

Check for name mismatches, syntax errors, other funky flaws...

bookworm
11-19-2003, 02:40 PM
thanks for the help. I appreciated it