Disable/enable onclick event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MEM

    Disable/enable onclick event

    hello,

    I'd like to 'disable' an image link based on a value selected in a
    drop down.

    I currently have an image link that has the onclick event set to
    execute a function.

    For example:

    <a href="#" onclick="afunct ion();return false;"><img
    src="blah.gif"> </a>

    So, based on what the user selects in a drop down i want the onclick
    event to NOT execute the function.

    On the opposite end i want the onclick event to execute the function
    if nothing is selected from the drop down.

    thanks in advance
  • Rick Measham

    #2
    Re: Disable/enable onclick event

    In article <9403d191.03102 91736.470e16be@ posting.google. com>,
    mmaxsom@citlink .net (MEM) wrote:
    [color=blue]
    > hello,
    >
    > I'd like to 'disable' an image link based on a value selected in a
    > drop down.
    >
    > I currently have an image link that has the onclick event set to
    > execute a function.
    >
    > For example:
    >
    > <a href="#" onclick="afunct ion();return false;"><img
    > src="blah.gif"> </a>
    >
    > So, based on what the user selects in a drop down i want the onclick
    > event to NOT execute the function.
    >
    > On the opposite end i want the onclick event to execute the function
    > if nothing is selected from the drop down.
    >
    > thanks in advance[/color]

    When you say 'nothing is selected from the drop down' I assume you mean
    if the selectedIndex is 0. In which case:


    <a href="#" onclick="if (theDropDown.se lectedIndex > 0) {
    afunction(); } else {document.locat ion='http://www.google.com' }">



    That will take you to google if nothing is selected in the drop down.

    It will execute afunction() if something it selected in the drop down.

    Comment

    Working...