I have already sent in a support request for this two days ago but I'm not getting an answer in a timely manner, so, I am posting this on the forum.
I have a menu with 6 menu items. I want the text and bgcolor for the individual menu items to toggle back and forth when the menu item is clicked.
I am trying to use the function mm_changeItemProperty() but I keep getting the following error in IE6:
"Microsoft JScript runtime error: '_mi[...].1' is null or not an object"
Here is my mm_changeItemProperty() function:
function mm_changeItemProperty(menuName, itemName, codeRef, newValue, updateDisplay)
{
menuNum=getMenuByName(menuName);
menuName = menuName.toLowerCase();
for (i=0; i<_mi.length; i++)
if (_mi[1].replace(/\ \;/ig,' ') == itemName && _m[_mi[0]][1] == menuName) break;
if (i == _mi.length) return;
_mi[codeRef] = newValue;
if (updateDisplay) BDMenu(_mi[0]);
}
Here is my function call:
mm_changeItemProperty('mapoptions', 'View<br>Cameras', 1, 'Hide<br>Cameras', 1);
As you can see, I am trying to change the menu item text 'View<br>Cameras' to 'Hide<br>Cameras'. From what I can tell, 'i' is exceeding the conditon of the for loop - _mi.length=5 but I get the error when i=6. The error occurs on ' if (_mi[1].replace(/\ \;/ig,' ') == itemName && _m[_mi[0]][1] == menuName)'.
I don't know if I'm suppose to have dowloaded some bolt-on module or what.
Can anyone help with this or suggest another way to change menu item properties dynamically?
Thanks,
Eric
mm_changeItemProperty
-
- Advanced
- Posts: 13
- Joined: Thu Oct 13, 2005 7:34 pm
mm_changeItemProperty()
The error occurs on ' if (_mi[1].replace(/\ \;/ig,' ') == itemName && _m[_mi[0]][1] == menuName)' is all I know. I don't know which _mi it is.
The for loop somehow exceeds the condition of i<_mi.length
I would like to point out that this function is from another thread concerning dynamically changing menu item properties. The link to the code is at:
http://support.milonic.com/demos/change ... /index.htm
Thanks,
Eric
The for loop somehow exceeds the condition of i<_mi.length
I would like to point out that this function is from another thread concerning dynamically changing menu item properties. The link to the code is at:
http://support.milonic.com/demos/change ... /index.htm
Thanks,
Eric
Hi gmester,
The "i" thing in that other code you mentioned is a different issue; you'll find an explanation here.
Eric,
I haven't been on the forums much lately, but I just stopped in and took an interest in your issue because I wrote that mm_changeItemProperty() function, although I notice that yours has an extra line in it:
That line isn't needed.
Anyway, I just tried a test, using the code you posted, and it worked fine for me (changed the text successfully). Is it possible that you are not passing the correct string for the itemName parameter? It is case sensitive, and must match exactly the text you used in the text= property of the menu item.
You mentioned that:
I'm not sure how that could happen... it's just a for loop. Since i isn't incremented within the loop, it should not be possible for it to exceed _mi.length.
If you can post a url to a page with this problem, then I should be able to tell you what's wrong. If you can't, then can you please post your menu_data.js code, and the code you are using to call mm_changeItemProperty()... if you post code, please use the forum's Code tags to preserve the formatting.
We'll get it figured out.
Kevin
The "i" thing in that other code you mentioned is a different issue; you'll find an explanation here.
Eric,
I haven't been on the forums much lately, but I just stopped in and took an interest in your issue because I wrote that mm_changeItemProperty() function, although I notice that yours has an extra line in it:
Code: Select all
menuNum=getMenuByName(menuName);
Anyway, I just tried a test, using the code you posted, and it worked fine for me (changed the text successfully). Is it possible that you are not passing the correct string for the itemName parameter? It is case sensitive, and must match exactly the text you used in the text= property of the menu item.
You mentioned that:
ecg921@gmail.com wrote: From what I can tell, 'i' is exceeding the conditon of the for loop - _mi.length=5 but I get the error when i=6. The error occurs on ' if (_mi[1].replace(/\ \;/ig,' ') == itemName && _m[_mi[0]][1] == menuName)'.
I'm not sure how that could happen... it's just a for loop. Since i isn't incremented within the loop, it should not be possible for it to exceed _mi.length.
If you can post a url to a page with this problem, then I should be able to tell you what's wrong. If you can't, then can you please post your menu_data.js code, and the code you are using to call mm_changeItemProperty()... if you post code, please use the forum's Code tags to preserve the formatting.
We'll get it figured out.
Kevin
I've got a similar problem (Error: '_mi[...].1' is null or not an object) using the function below but only before the first click on the menu.Shap5202 wrote:do you know which _mi[...][1] is causing the error?you've got it in 3 different places. maybe just put some null checks around the code?
Could you help me pls ?
Code: Select all
var mm_separator = " > ";
var mm_selectionSequence = "";
function mm_openUrl(url)
{
url+="?"+_itemRef;
window.location.href = url;
}
function mm_getSelectionSequence()
{
var selectedItem = location.search.slice(1);
var i = selectedItem;
do {
if (mm_selectionSequence == "")
mm_selectionSequence = _mi[i][1];
else
mm_selectionSequence = _mi[i][1] + mm_separator + mm_selectionSequence;
i = getParentItemByItem(i);
} while (!isNaN(i));
}
Sorry 'bout that... my fault for sloppy coding. In my defense, I had sort of slapped that example together for a specific user a long time ago; never really though that others would end up using it. Anyway, the reason you get the error message before the first click is because the mm_getSelectionSequence() function runs automatically on every page that contains your menu_data.js file (because it's called at the bottom of that file). When it runs, the function parses the "clicked" menu item that was passed to the current page from the previous page. This presents a logical error on the very first page visited, because there was no "previous" page where a menu item was clicked. Therefore, i is undefined on the first page. Again... sorry 'bout that!gerarcyr wrote:... but only before the first click on the menu.
Could you help me pls ?
Try replacing mm_getSelectionSequence() with the following version
Code: Select all
function mm_getSelectionSequence()
{
if(location.search == "") return;
var i = location.search.slice(1);
do {
if (mm_selectionSequence == "")
mm_selectionSequence = _mi[i][1];
else
mm_selectionSequence = _mi[i][1] + mm_separator + mm_selectionSequence;
i = getParentItemByItem(i);
} while (!isNaN(i));
}
Cheers,
Kevin