kralco626
kralco626

Reputation: 8624

javascript or jquery event that fires whenever the selected value of a select changes

I know i can use the javascript event onchange, or the jquery event change, however, enother of these cover the senario when the user does not change the value of the select him self.

For example, when using javascripts onchange event if I have three cascading selects and I select the first one, and the second one populates and the default value if the second one is the one the user wants, the onchange event of the second select is never fired, hence the third select is never populated.

ideas?

Upvotes: 0

Views: 402

Answers (5)

Praveen Prasad
Praveen Prasad

Reputation: 32107

two ways you can do

1> on second <select> create first option with value= "[choose something]" this way user will be forced to choose some thing from select2

2> When you populate the second select ,trigger its onchange event

Upvotes: 2

James Young
James Young

Reputation: 1432

If your changing the content via javascript, you can also trigger the change event explicitly.

Upvotes: 0

Belinda
Belinda

Reputation: 1231

Autopopulate the third select box with the values it should have for the default of the second is one option. Otherwise as others have suggested a Please Choose option that forces onchange to fire.

Upvotes: 0

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114367

Insert a dummy item in the second select as the first item:

<option value="">-- select one --<option>

That way the user must fire the change event to select an item,

Upvotes: 0

Sednus
Sednus

Reputation: 2113

How about putting a dummy value at the beginning on the select ,like a blank option. So that the user is forced to select another that has a value.

Upvotes: 0

Related Questions