Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

object expected

Status
Not open for further replies.

oll3i

Programmer
Apr 15, 2007
5
PL
i'm writing a menu in javascript.i want the links to change onmouseover and onmouseclick and of course onmouseout
but when i roll over the links i get object expected error

i defined javascript class as follows

function Menu(variables here){
assigning here

this.display = function(){
document.write here eg

document.write('<li><a href=\"path\" id=\"c\" onmouseover=\'changeLikStyleOn("c")\'></a>');
}

function changeLinkStyleOn(id)
var li= document.getElementById(id);
style definition here
}

function changeLinkStyleOut(id){
var li= document.getElementById(id);
style definition here
}
}


Thank You
 
It seems like this line:
document.write('<li><a href=\"path\" id=\"c\" onmouseover=\'changeLikStyleOn("c")\'></a>');
changeLIKStyleOn -> changeLiNkStyleOn

miss the 'n' of Link





 
no i ate one letter i typed that i didnt copy and paste cos the script is on different computer
in my script it is changeLinkStyleOn
 
Perhaps you could paste the real script, as if there's one typo, chances are there are more.

Working with non-real examples usually makes for painful debugging when the real code is finally presented... so why not save us both time & trouble and give the real code?

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
function Menu(modul,variables here)
{
this.modul=modul;

this.display= function() {

document.write('<ul style=\'float:left;margin:0;padding:0;list-style:none;\'>');
document.write('<li style=\'display:inline;\'><a href=\'/HRDB/candidates/index.jsp?sortby=name,f=1,switch_f=1,modul=candidates\' id=\"candidates\" onclick=\'changeLinkStyleOn("candidates")\' onmouseover=\'changeLinkStyleOn("candidates")\' onmouseout=\'changeLinkStyleOut("candidates")\' style=\'width:80px;height:22px;float:left;margin:0 1px 0 0;font-size:100%;text-decoration:none;text-align:center;color:#FFF;font-weight:bold;background:url(../images/top_menu_normal.gif) left top no-repeat;padding:3px 0 0 0;\'>');
document.write(this.var1);
document.write('</a></li>');
if(this.modul=="candidates"){
document.write('<div style=\'position:absolute;width:818px;height:10px;margin:0;padding:0;font-size:100%;\'>');
document.write('<ul style=\'position:relative;margin:0;padding:0;bottom:-1.4em;left:-150px;font-size:100%;width:818px;\'>');
document.write('<li style=\'display:inline;list-style:none;border-right:1px solid #CCC;padding-right:2px;\'><a style=\'text-decoration:none;color:#000;\' href=\'/candidates/insert.jsp?modul=candidates\'>');
document.write(this.var11);
document.write('</a></li>');
document.write('<li style=\'display:inline;list-style:none;border-right:1px solid #CCC;padding-right:2px;\'><a style=\'text-decoration:none;color:#000;\' href=\'candidates/search.jsp?modul=candidates\'>');
document.write(this.var12);
document.write('</a></li>');
document.write('<li style=\'display:inline;list-style:none;border-right:1px solid #CCC;padding-right:2px;\'><a style=\'text-decoration:none;color:#000;\' href=\'#\'>');
document.write(this.var14);
document.write('</a></li>');
document.write('<li style=\'display:inline;list-style:none;\'><a style=\'text-decoration:none;color:#000;\' href=\'../logout.jsp\'>[');
document.write(this.var15);
document.write(']</a></li>');
document.write('</ul>');
document.write('</div>');
}
document.write('<li style=\'display:inline;\'><a href=\'/HRDB/clients/index.jsp?sortby=name,f=1,switch_f=1,modul=clients\' id=\'clients\' onClick=\'this.changeLinkStyleOn(this.id)\' onMouseOver=\'this.changeLinkStyleOn(this.id)\' onMouseOut=\'this.changeLinkStyleOut(this.id)\' style=\'width:80px;height:22px;float:left;margin:0 1px 0 0;font-size:100%;text-decoration:none;text-align:center;color:#FFF;font-weight:bold;background:url(../images/top_menu_normal.gif) left top no-repeat;padding:3px 0 0 0;\'>');
document.write(this.var2);
document.write('</a></li>');
if(this.modul=="clients"){
document.write('<ul style=\'position:relative;margin:0;padding:0;bottom:-1.4em;left:1px;font-size:100%;width:818px;\'>');
document.write('<li style=\'display:inline;list-style:none;border-right:1px solid #CCC;\'><a href=\'/candidates/insert.jsp?modul=candidates\'>');
document.write(this.var11);
document.write('</a></li>');
document.write('<li style=\'display:inline;list-style:none;border-right:1px solid #CCC;\'><a href=\'candidates/search.jsp?modul=candidates\'>');
document.write(this.var13);
document.write('</a></li>');
document.write('<li style=\'display:inline;list-style:none;border-right:1px solid #CCC;\'><a href=\'#\'>');
document.write(this.var14);
document.write('</a></li>');
document.write('<li style=\'display:inline;list-style:none;\'><a href=\'../logout.jsp\'>[');
document.write(this.var15);
document.write(']</a></li>');
document.write('</ul>');
}
document.write('</ul>');
document.write('</li>');

}


function changeLinkStyleOn (id){
var li= document.getElementById(id);
li.style.width='80px';
li.style.float='left';
li.style.display='block';
li.style.textAlign='center';
li.style.marginTop='0';
li.style.marginRight='1px';
li.style.marginBottom='0';
li.style.marginLeft='0';
li.style.fontSize='100%';
li.style.textDecoration='none';
li.style.color='#FFF';
li.style.fontWeight='bold';
li.style.background='url(../images/top_menu_hover.gif) left top no-repeat';
}

function changeLinkStyleOut(id){
var li= document.getElementById(id);
li.style.width='80px';
li.style.float='left';
li.style.display='block';
li.style.textAlign='center';
li.style.marginTop='0';
li.style.marginRight='1px';
li.style.marginBottom='0';
li.style.marginLeft='0';
li.style.fontSize='100%';
li.style.textDecoration='none';
li.style.color='#FFF';
li.style.fontWeight='bold';
li.style.background='url(../images/top_menu_normal.gif) left top no-repeat';
}
}

the menu displayes i get the error when i roll over or click the tabs

thank You
 
onMouseOver=\'[!]this.[/!]changeLinkStyleOn(this.id)\'

Get rid of the [tt]this.[/tt] at the start. The function [tt]changeLinkStyleOn[/tt] is not a member function of the anchor tag. Same goes for your [tt]onClick[/tt] and [tt]onMouseOut[/tt] handlers.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top