I've been wrestling with this problem since yesterday, and I'm no closer to solving it than I was then.
Here's the scenario:
I have a page with two frames. A frame named 'menuFrame' at the top, and a frame named 'mainFrame' below.
'menuFrame' contains a table, named 'menu1'. It has one row with 6 cells in the row. Each cell has a different id.
The idea is that each cell contains a menu option which can either be 'on' or 'off' depending on its class.
I've been trying to write a JavaScript function called 'MenuSwitchOn(SwitchMenu)' which will do two things:- It will set the class of all the cells to 'off'
- It will set the class of the cell specified by 'SwitchMenu' to 'on'.
Here's the function I came up with (it says PHP but it's really JavaScript):
PHP Code:
function MenuSwitchOn(switchMenu) {
var menulength = window.frames['menuFrame'].menuRow.cells.length;
for (var i=0; i<menulength; i++) {
window.frames['menuFrame'].menu1.rows[0].cells[i].class = 'off';
if (switchMenu && window.frames['menuFrame'].menu1.rows[0].cells[i].id==switchMenu) {
var switchOn = i;
}
}
if(switchMenu) {
window.frames['menuFrame'].menu1.rows[0].cells[switchOn].class = 'on';
}
}
The problem is I keep getting an error "missing name after . operator" on the following line:
Code:
window.frames['menuFrame'].menu1.rows[0].cells[i].class = 'off';
Does anyone have any advice for me? I'm pretty new at JavaScript...
Bookmarks