Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Trigger change event (urgent)

Reply
Thread Tools

Trigger change event (urgent)

 
 
R. Rajesh Jeba Anbiah
Guest
Posts: n/a
 
      04-15-2004
I have Googled a lot, but couldn't still find the answer...

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

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

More specifically, I have something like:
<select name="sel" onChange="alert(this.selectedIndex)">
<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.selectedIndex = 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
 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      04-15-2004
R. Rajesh Jeba Anbiah wrote:
<snip>
> and I have something in JS like:
> form1.sel.selectedIndex = 2; //changing

<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.onchange();

Richard.


 
Reply With Quote
 
 
 
 
R. Rajesh Jeba Anbiah
Guest
Posts: n/a
 
      04-15-2004
"Richard Cornford" <(E-Mail Removed)> wrote in message news:<c5l77h$ev4$1$(E-Mail Removed)>...
> R. Rajesh Jeba Anbiah wrote:
> <snip>
> > and I have something in JS like:
> > form1.sel.selectedIndex = 2; //changing


<snip>
> then you can just call
> the - onchnge - handler function yourself as:-
>
> form1.sel.onchange();


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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
TkInter bind() event is not firing event trigger Anthony Papillion Python 3 06-23-2010 12:55 AM
How can the change of second window trigger change of first window xhe Javascript 1 02-09-2007 06:16 PM
How to trigger the CheckBox1_CheckedChanged event by change the checked value by code? David ASP .Net 3 12-02-2004 10:16 PM
Can a validation control trigger an property change on a web form? Pasta Bolognese ASP .Net 1 05-10-2004 06:13 PM
Could lease-IP-change trigger event? hiwa Java 1 02-23-2004 12:25 AM



Advertisments