473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

peculiar behavior of safari onchange event

This only happens with Safari but works fine in IE and FireFox.

I call a function in on change event of select element in a form. the function is not only called when a change is made to the select element but also when the focus is out of the select element. can anyone tell me a work around to this problem? thanks..
Nov 15 '07 #1
6 6467
gits
5,390 Expert Mod 4TB
hi ...

welcome to TSDN ...

please post the code you are using and thet makes the problem ...

kind regards
Nov 15 '07 #2
Logician
210 100+
This only happens with Safari but works fine in IE and FireFox.

I call a function in on change event of select element in a form. the function is not only called when a change is made to the select element but also when the focus is out of the select element. can anyone tell me a work around to this problem? thanks..
I reported this bug (in Safari Win) a few weeks ago. The only workaround I can think of now is to record the initial value of the select, then code the onchange handler to ensure that the value has actually changed before taking any action.
Nov 15 '07 #3
hi ...

welcome to TSDN ...

please post the code you are using and thet makes the problem ...

kind regards
Thanks a lot for responding immediately. Your help is greatly appreciated.
I just try to reproduce the code. I am not giving you the exact code since it seems too long and would be out of the scope of this problem. so i give you just a simple snippet that would make you understand my problem. thanks

Description of the code:
when i select an item from the select(combo) box the alert hi appears and when i click the button or press the button the alert hi appears again. but i need the alert hi to appear only once.

[HTML]<script type="text/javascript">
function myFunction() {
alert("hi");
}
</script>
<form>
<select name="state" onChange="myFunction()">
<option value="">select state</option>
<option value="state1">state1</option>
<option value="state2">state2</option>
</select>
<input type="button" name="myButton" value="Click Here">
</form>[/HTML]
Nov 16 '07 #4
I reported this bug (in Safari Win) a few weeks ago. The only workaround I can think of now is to record the initial value of the select, then code the onchange handler to ensure that the value has actually changed before taking any action.
Thank you very much for the workaround. For now I have used this and it seems to work fine except the focus goes to the another select. exactly i use a state select and city select. after the users selects a state the city is loaded using ajax and when i click the city select element the drop down shows the cities listed and immeditely disappears because the call to the function of the state is triggered(since the focus left the state select). so the user has to select the city twice. the first time the user is not able to select the city because of the function call and second time after the function call is finished the user is able to select a city.
Nov 16 '07 #5
I reported this bug (in Safari Win) a few weeks ago. The only workaround I can think of now is to record the initial value of the select, then code the onchange handler to ensure that the value has actually changed before taking any action.
Thank you for your help. Your suggestion greatly helped. I too found some workaround for my specific problems. Thankss a lot.
Nov 16 '07 #6
acoder
16,027 Expert Mod 8TB
Glad you got it working.

I am surprised that this was not picked up. It's such a basic bug which even IE does not have.
Nov 17 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: The Mess | last post by:
Here's a simple example of my problem... Create a new Activex Control and just put a ComboBox on it. Add a project and site the new Control. Add this to the Form code. and run it. ...
1
by: Covad | last post by:
Hi all, For some reason my change() function is only called when the page loads. I'd much rather it gets called when the select changes. Here's the code: window.onload = init; function...
2
by: Asit | last post by:
In JavaScripts checks for an onChange event against the value of the textbox at the time of the last onChange event. Since an onChange Event never fired after you changed the text first time ,...
4
by: ioneabu | last post by:
I am trying to do the basic task of setting a text field from the choice made from a select box. I learned how to code it from my O'Reilly Javascript reference which is a few years old. The code...
3
by: b_naick | last post by:
I realize that the onChange event for a drop down can be trapped as follows: <select name="myDropDown" onChange="somefunc"> Is it possible to trap the onChange event outside of the select...
4
by: mr.fullzero | last post by:
Our team have extracted code sample that caused abnormal Safari termination. The crash seems to happen any time, when user selects an option and closes alert popup. The version of Safari is 10.4.6....
1
by: rynato | last post by:
I ran into an interesting problem while working on a form: I have a drop down list (think <form><select><option>...) of 'open sessions' which a user can choose from to continue entering data....
5
by: HemalGati | last post by:
hi friends, can anyone tell me why onchange() event input type select is not working in MAC safari. is there any alternative of this problem. i have written the following code : ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.