Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change an Event from within another Event?

Status
Not open for further replies.

apparition

Technical User
Aug 8, 2001
34
US
OK say I have a select box with a bunch of options in it. I have a javascript function that runs when the select is changed (onChange) and goes to another page.

Its all fine and good until you try to navigate the option box without a mouse. Now everytime you tab to the select box and try to press down to see the options, it calls the function and off you go to the next page.

Me thinking that I was smart, change it from onChange to onKeyPress. Well now the keyboard works just fine, but when I use the mouse I actually have to hit a key to get it to work.

The next step naturally was to try onClick. Now when you click with the mouse to see the options, the function is immediately called.

The only solution I could think of was to use the onKeyPress for the keyboard people and for the mouse people, use onClick to change the onChange event.

All that typin and all I really want to know is if I can modify or assign the onChange value of the select box from within its own onClick event?

Any help is good help...
Thanks
 
apparition,
I understand the problem. I want to suggest another solution, completely different one. Do not call any function when select option is changed. Add a button instead, that the user will have to click on after he makes his choice.

It has also another advantage: if some option will be selected by mistake, it can be easily changed. (I think everybody knows this situation when you select not what you wanted, but a page starts reloading. Then you have to stop it and reload back to repeat the action.)

This is the best solution if you think about usability.
 
Thanks for the suggestion. Actually I agree with you that a button would be best but unfortunately our client is kinda stuck on the 'no button' thing. I really do appreciate your input though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top