PDA

View Full Version : Can't format this right.


ScottInTexas
11-24-2002, 05:48 PM
The scrip works and if I allow scrolling in the iframe you can scroll to the menu items. I want to add OnClick to the TD tags (if allowed) but first I want to at least see it the way I want.

Here is the pertinent code.

<SCRIPT type="text/javascript">
function SetMenu(){
var aryItems=new Array("Garbage"," ", "Calendar of Events", "Cal","Whats New", "New", "For Sale","Sale","Contact Us","email","FAQ","FAQ");
var bigtxt;
var begmark;
var endmark;
var MenuText;
begmark='<TABLE><TR>';
endmark='</TR></TABLE>';
bigtxt=begmark;
for (i=0;i<aryItems.length;i++){
MenuText=aryItems[i];
bigtxt=bigtxt+'<TD style="MenuItem">' + MenuText + '</TD>';
i++;
}
bigtxt=bigtxt+endmark;
parent.menubar.document.write(bigtxt);
}
</script>
</head>

<body onload="SetMenu()">

<Div Class="Header">Sweeny Horse 4-H Club<br>'Making the best better!'</DIV>
<iframe name="menubar" width="100%" class="menu" valign="top" scrolling="no" height="20"></iframe>

blah
blah
blah

</body>
</HTML>

I may be approaching the whole thing wrong, so your comments on that are welcome. The idea is that I have a simple menu at the top of the screen. I know there are probably 2000 downloadable menus but I want to do my own.

Thanks for the help!

Scott

Mr J
11-24-2002, 07:07 PM
Try This





<SCRIPT type="text/javascript">
function SetMenu(){
var aryItems=new Array("Garbage"," ","Calendar of Events","Cal","Whats New","New","For Sale","Sale","Contact Us","email","FAQ","FAQ2");

var bigtxt;
var begmark;
var endmark;
var MenuText;
begmark='<TABLE>';
endmark='</TABLE>';
bigtxt=begmark;
for (i=0;i<aryItems.length;i++){
MenuText=aryItems[i];
bigtxt=bigtxt+'<TR><TD style="MenuItem" onclick="parent.qwerty('+[i]+')">' + MenuText + '</TD></TR>';
}
bigtxt=bigtxt+endmark;
parent.menubar.document.write(bigtxt);
}

function qwerty(n){
alert("This is onclick event No. "+n)
}
</script>
</head>

<body onload="SetMenu()">

<Div Class="Header">Sweeny Horse 4-H Club<br>'Making the best better!'</DIV>
<iframe name="menubar" width="100%" class="menu" valign="top" scrolling="yes" height="250"></iframe>

blah
blah
blah