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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

functional context menu

Status
Not open for further replies.

smitheroo

Programmer
Aug 30, 2008
15
GB
Hi,

I've created a right click context menu and I'm wondering if anyone knows how to add an onclick event to the menu items (I'm trying to show and hide content with an onclick callin a seperate show/hide script).

I think the code below is the right place to play with the functionality of making the links useful, rather than just displaying an alert message.



Code:
    var OnClick = function(Sender, EventArgs)
    {
        switch(EventArgs.CommandName)
        {
        case 'Release':
            alert('Text: ' + EventArgs.Text);
            break;
        case 'Save':
            alert('Text: ' + EventArgs.Text);
            break;
        case 'Update':
            alert('Text: ' + EventArgs.Text);
            break;
        case 'Cancel':
           alert('Text: ' + EventArgs.Text);
           break;

        }

the whole code is from:

many thanks
Ian
 
I'm wondering if anyone knows how to add an onclick event to the menu items

Assuming you have a pointer to the object in question, you can do:

Code:
el.onclick = func;

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks for your response Dan.

I'm not quite sure how that fits into the snippet of code, but at least I can google that line of code for an example.

(I'm a designer and a bit green with javascript)

Cheers

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top