View Full Version : Triggering onChange/Dropdown

06-05-2003, 03:11 AM
Another problem... :)

I have a double combo box working fine with javascript. What I would like to do is to be able to select/change the first combo box from a menu or from somewhere besides actually choosing an item in the drop down menu.

The problem is that when I got to change it using the DOM the second combo box is NOT updating it's value the way it should be. The function for the combo box is originally called using the onChange="function(this)" command.

Is there a way to trigger the onChange somehow? Whenever I send a value into the function directly the second combo box never updates.

Here's the function:

function productselected(elem){
for (var i = document.f1.productLine.options.length; i >= 0; i--){
document.f1.productLine.options[i] = null;

Any help would be greatly appreciated. Thanks.

06-05-2003, 04:20 AM
You can call an HTML event handler explicitly:


Hard to tell if this is helpful.

06-05-2003, 04:39 AM
or after changing the select, call the onchange function manually.

06-05-2003, 05:02 AM
The problem I'm having is the form originally uses:


and I'm not sure exactly what value 'this' is sending to the function so I'm not sure what value to send. I'm trying all kinds of different combinations but with no success.

06-05-2003, 05:06 AM

It's not a value - it's the Select object. Did you try calling it explicitly (above)?

06-05-2003, 05:47 AM

06-05-2003, 05:55 AM
I was able to grab some help and I think the problem is solved. I'll post the script so other people can use it if they run into the same problem.

I really do appreciate your help and patience though Cheesebagpipe and Glenngv.

<script type="text/javascript">
function see(sel) {
function activateOnChange() {
var s = document.forms["ff"].elements["ss"]
// -->

<form action="" name="ff">
<select onchange="see(this)" name="ss">
<option value="111">aaaaa</option>
<option value="222">bbbbb</option>
<a href="#" onclick="activateOnChange()">Activate onChange</a>

06-05-2003, 04:44 PM
You're using IE-only DHTML behaviors. With so many ways to do this, why choose a proprietary one?

06-05-2003, 05:33 PM
Yikes.. I didn't realize that..

Okay.. I did try calling the function using your syntax above:


which came back with an error.

I also tried calling the function and passing in a value as Glenngv suggested but also had no luck:


I feel like a damn moron.. Obviously I'm looking for a non-browser specific answer. The way I got the previous IE only function to call was to put it in the onLoad handler so each time the page is refreshed it will automatically do it.. and that seemed to work fine.

I'm baffled and frustrated (as I'm sure you are with my babbling :) )..

06-05-2003, 06:29 PM
Look, you babbling moron (:D :D :D)


If that don't cut it, post some of the relevant code, along with some more moronic babbling...:D :D

06-05-2003, 06:50 PM

a sense of humour is becoming the only thing keeping me going. :)

Okay.. I think what you just gave me is working.. I'm sure I tried that at some point during my 16 hours of coding yesterday.. But of course what actually happened past hour 12 is anybody's guess.


Netscape = bad.. Now that IE works fine.. It's on to tackle Netscape which should be next to impossible :) . .. crap