Trigger change event (urgent)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • R. Rajesh Jeba Anbiah

    Trigger change event (urgent)

    I have Googled a lot, but couldn't still find the answer...

    I could see, I can trigger the "click" event like:
    button_object.C lick()

    But, I need to trigger the onChange() of select options. I couldn't
    find anything like:
    select_object.C hange()

    More specifically, I have something like:
    <select name="sel" onChange="alert (this.selectedI ndex)">
    <option value="1" selected>1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    </select>

    and I have something in JS like:
    form1.sel.selec tedIndex = 2; //changing
    If I change the index, it doesn't trigger the onChange event. I
    wish to trigger the change event. Is there anyway to go with
    JavaScript or JScript? TIA.

    --
    http://www.sendmetoindia.com - Send Me to India!
    Email: rrjanbiah-at-Y!com
  • Richard Cornford

    #2
    Re: Trigger change event (urgent)

    R. Rajesh Jeba Anbiah wrote:
    <snip>[color=blue]
    > and I have something in JS like:
    > form1.sel.selec tedIndex = 2; //changing[/color]
    <snip>

    Assuming - form1 - is a local variable holding a reference to the form
    element (rather than a browsers specific shortcut reference, with the
    consequent removal of any hope of cross browser support for a task that
    every javascript enabled browser is capable of), then you can just call
    the - onchnge - handler function yourself as:-

    form1.sel.oncha nge();

    Richard.


    Comment

    • R. Rajesh Jeba Anbiah

      #3
      Re: Trigger change event (urgent)

      "Richard Cornford" <Richard@litote s.demon.co.uk> wrote in message news:<c5l77h$ev 4$1$8302bc10@ne ws.demon.co.uk> ...[color=blue]
      > R. Rajesh Jeba Anbiah wrote:
      > <snip>[color=green]
      > > and I have something in JS like:
      > > form1.sel.selec tedIndex = 2; //changing[/color][/color]

      <snip>[color=blue]
      > then you can just call
      > the - onchnge - handler function yourself as:-
      >
      > form1.sel.oncha nge();[/color]

      Oh cool! Thanks a lot. Never thought that it will be this much
      easier:) Thanks again.

      --
      http://www.sendmetoindia.com - Send Me to India!
      Email: rrjanbiah-at-Y!com

      Comment

      Working...