Hi... I'm trying to catch a click on a menu item with the following
code:

var menuApplyrule =
document.getElementById('_MIonActionMenuClickapplyrule10001');
menuApplyrule.onClick = function()
{
alert("onClick!!")

}

I have also tried with

document.getElementById('_MIonActionMenuClickapplyrule10001').onclick
= function()
.... and so on

The code is included in the onLoad event on the CRM Form. But it
does'nt work!

How do I catch a click on a menu item in CRM?

Re: Problem with onClick on Menu Item in CRM 3.0 (and 4.0?) by Dodd

Dodd
Wed Jul 23 08:03:27 CDT 2008

Try this:

var applyRule = "_MIonActionMenuClickapplyrule10001";
var mnuItem = document.getElementById(applyRule);

// Click Interception Code
if(mnuItem != null)
{
document.all._MIonActionMenuClickapplyrule10001.onclick =
function()
{
//put your code here
alert("OnClick");
}
}

Re: Problem with onClick on Menu Item in CRM 3.0 (and 4.0?) by Thomas

Thomas
Wed Jul 23 08:36:17 CDT 2008

Thank you for your time Dodd...

It does'nt work, propaply because the element allready has an action:
<TR action=3D"onActionMenuClick('applyrule', 10001)"
id=3D"_MIonActionMenuClickapplyrule10001">

I need to check a checkbox, and if checked, I need to disable the Menu
Item, so it cant be clicked.... I have tried changing innerHTML on the
element but without luck. I'm not able to overwrite it (the same with
innerText)

How do I disable or set visibility =3D 'hidden' to a Menu Item in
runtime?

On 23 Jul., 15:03, Dodd <MDod...@gmail.com> wrote:
> Try this:
>
> var applyRule =3D "_MIonActionMenuClickapplyrule10001";
> var mnuItem =3D document.getElementById(applyRule);
>
> // Click Interception Code
> if(mnuItem !=3D null)
> {
> =A0 =A0 document.all._MIonActionMenuClickapplyrule10001.onclick =3D
> function()
> =A0 =A0 {
> =A0 =A0 =A0 =A0 =A0//put your code here
> =A0 =A0 =A0 =A0 =A0alert("OnClick");
> =A0 =A0 =A0}
>
> }


Re: Problem with onClick on Menu Item in CRM 3.0 (and 4.0?) by Thomas

Thomas
Wed Jul 23 09:11:29 CDT 2008

mnuItem.style.display =3D 'none';

Sorry, I'm getting tired...;-)

On 23 Jul., 15:36, Thomas <tdem...@gmail.com> wrote:
> Thank you for your time Dodd...
>
> It does'nt work, propaply because the element allready has an action:
> <TR action=3D"onActionMenuClick('applyrule', 10001)"
> id=3D"_MIonActionMenuClickapplyrule10001">
>
> I need to check a checkbox, and if checked, I need to disable the Menu
> Item, so it cant be clicked.... I have tried changing innerHTML on the
> element but without luck. I'm not able to overwrite it (the same with
> innerText)
>
> How do I disable or set visibility =3D 'hidden' to a Menu Item in
> runtime?
>
> On 23 Jul., 15:03, Dodd <MDod...@gmail.com> wrote:
>
> > Try this:
>
> > var applyRule =3D "_MIonActionMenuClickapplyrule10001";
> > var mnuItem =3D document.getElementById(applyRule);
>
> > // Click Interception Code
> > if(mnuItem !=3D null)
> > {
> > =A0 =A0 document.all._MIonActionMenuClickapplyrule10001.onclick =3D
> > function()
> > =A0 =A0 {
> > =A0 =A0 =A0 =A0 =A0//put your code here
> > =A0 =A0 =A0 =A0 =A0alert("OnClick");
> > =A0 =A0 =A0}
>
> > }


Re: Problem with onClick on Menu Item in CRM 3.0 (and 4.0?) by Thomas

Thomas
Wed Jul 23 09:22:02 CDT 2008

I still need to set the value of the checkbox BEFORE
action=3D"onActionMenuClick('applyrule', 10001)" is fired...

I tried with mnuItem.addEventListener("click", modifyText, false);
without result... modifyText is not called...

How do I add som func BEFORE the action-code is called??

THANKS!


On 23 Jul., 16:11, Thomas <tdem...@gmail.com> wrote:
> mnuItem.style.display =3D 'none';
>
> Sorry, I'm getting tired...;-)
>
> On 23 Jul., 15:36, Thomas <tdem...@gmail.com> wrote:
>
> > Thank you for your time Dodd...
>
> > It does'nt work, propaply because the element allready has an action:
> > <TR action=3D"onActionMenuClick('applyrule', 10001)"
> > id=3D"_MIonActionMenuClickapplyrule10001">
>
> > I need to check a checkbox, and if checked, I need to disable the Menu
> > Item, so it cant be clicked.... I have tried changing innerHTML on the
> > element but without luck. I'm not able to overwrite it (the same with
> > innerText)
>
> > How do I disable or set visibility =3D 'hidden' to a Menu Item in
> > runtime?
>
> > On 23 Jul., 15:03, Dodd <MDod...@gmail.com> wrote:
>
> > > Try this:
>
> > > var applyRule =3D "_MIonActionMenuClickapplyrule10001";
> > > var mnuItem =3D document.getElementById(applyRule);
>
> > > // Click Interception Code
> > > if(mnuItem !=3D null)
> > > {
> > > =A0 =A0 document.all._MIonActionMenuClickapplyrule10001.onclick =3D
> > > function()
> > > =A0 =A0 {
> > > =A0 =A0 =A0 =A0 =A0//put your code here
> > > =A0 =A0 =A0 =A0 =A0alert("OnClick");
> > > =A0 =A0 =A0}
>
> > > }


Re: Problem with onClick on Menu Item in CRM 3.0 (and 4.0?) by Dodd

Dodd
Wed Jul 23 18:09:46 CDT 2008

Try this:

// OnLoad event code:
var checkBox = crmForm.all.new_disablemenubutton.DataValue;
var applyRule = "_MIonActionMenuClickapplyrule10001";
var mnuItem = document.getElementById(applyRule);
if(checkBox == true)
{
mnuItem.style.display='none';
}
else
{
mnuItem.style.display='';
}

// To handle hiding the button unless the checkbox is checked
var eventHandler = function()
{
switch(crmForm.all.new_disablemenubutton.DataValue)
{
case true:
mnuItem.style.display='';
break;
case false:
mnuItem.style.display='';
break;
}
}
crmForm.all.new_disablemenubutton.onclick = eventHandler;

This way, if the user checks the checkbox, the Menu Item is hidden, if
un-checked, it is displayed. The OnLoad keeps it from re-appearing
when the record is saved or refreshed.

--MD


Re: Problem with onClick on Menu Item in CRM 3.0 (and 4.0?) by Thomas

Thomas
Thu Jul 24 01:56:18 CDT 2008

THANKS once again Dodd!

Your code works fine, but I need to set the checkbox when the user
clicks on the Menu. The checkbox is read-only, it must be checked when
the user clicks on the mnuItem

The problem is that it all ready has a action: <TR
action=3D"onActionMenuClick('applyrule', 10001)"
id=3D"_MIonActionMenuClickapplyrule10001">

I need to add an eventhandler which registers the menu click, sets the
checkbox =3D true and mnuItem.style.display =3D 'none' AND it must
continue with the action all ready made by MS.... How do I do that?
Thank you...

On 24 Jul., 01:09, Dodd <MDod...@gmail.com> wrote:
> Try this:
>
> // OnLoad event code:
> var checkBox =3D crmForm.all.new_disablemenubutton.DataValue;
> var applyRule =3D "_MIonActionMenuClickapplyrule10001";
> var mnuItem =3D document.getElementById(applyRule);
> if(checkBox =3D=3D true)
> {
> =A0 =A0 mnuItem.style.display=3D'none';}
>
> else
> {
> =A0 =A0 mnuItem.style.display=3D'';
>
> }
>
> // To handle hiding the button unless the checkbox is checked
> var eventHandler =3D function()
> {
> =A0 =A0 switch(crmForm.all.new_disablemenubutton.DataValue)
> =A0 =A0 {
> =A0 =A0 =A0 =A0 case true:
> =A0 =A0 =A0 =A0 =A0 =A0 mnuItem.style.display=3D'';
> =A0 =A0 =A0 =A0 =A0 =A0 break;
> =A0 =A0 =A0 =A0 case false:
> =A0 =A0 =A0 =A0 =A0 =A0 mnuItem.style.display=3D'';
> =A0 =A0 =A0 =A0 =A0 =A0 break;
> =A0 =A0 }}
>
> crmForm.all.new_disablemenubutton.onclick =3D eventHandler;
>
> This way, if the user checks the checkbox, the Menu Item is hidden, if
> un-checked, it is displayed. The OnLoad keeps it from re-appearing
> when the record is saved or refreshed.
>
> --MD