473,624 Members | 2,615 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onchange event is not trigger when drop down size = 1

The following code won't work, because onchange event is not trigger
when drop down size = 1. But if I make the size="2" or greater, then
it will work. Is that true? please advise. thanks!!

<script type="text/javascript">
function showRange()
{ alert("showRang e");
}
</script>
<SELECT NAME="range" SIZE="1" onchange="showR ange();">
<OPTION VALUE="0">addre ss 1</OPTION>
</SELECT>
Jul 23 '05 #1
2 4225
"Matt" <jr********@hot mail.com> wrote in message
news:ba******** *************** ***@posting.goo gle.com...
The following code won't work, because onchange event is not trigger
when drop down size = 1. But if I make the size="2" or greater, then
it will work. Is that true? please advise. thanks!!

<script type="text/javascript">
function showRange()
{ alert("showRang e");
}
</script>
<SELECT NAME="range" SIZE="1" onchange="showR ange();">
<OPTION VALUE="0">addre ss 1</OPTION>
</SELECT>


For "onChange() " to be detected one must move to a different <option>.

Often there is a blank <option> at the head of the list.
Jul 23 '05 #2
Matt wrote:
The following code won't work, because onchange event is not trigger
when drop down size = 1. But if I make the size="2" or greater, then
it will work. Is that true? please advise. thanks!!

<script type="text/javascript">
function showRange()
{ alert("showRang e");
}
</script>
<SELECT NAME="range" SIZE="1" onchange="showR ange();">
<OPTION VALUE="0">addre ss 1</OPTION>
</SELECT>


It works fine if you have more than one <option>. If you only have a
single option, there is nothing to "change", so no "onchange" event can
be triggered. The reason it works if have a single <option> and you
specify size="2" is because you now have your defined <option> and an
empty, undefined space for an option. The user can now click that blank
entry, cause a "change" in the item selected which fires the onchange
event.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
7637
by: Ryan McGeary | last post by:
In a <select> drop-down, the onchange event isn't called when scrolling through the dropdown using the mouse-wheel and when crossing over a new <optgroup>. Using the example below, notice how the onchange event isn't called when mouse wheel scrolling between A3 and B1, but it works properly when scrolling between A1 and A2. E.g. ------------------------------------------
4
11941
by: rick | last post by:
The following basic script works fine in firefox by not in IE. Can anyone spot the problem? In IE I can only delete the first line but not the lines created by javascript. Also, look at the HTML code for the first line (click the Table HTML button:)) you will fine that the code displayed is not the same as was written. "onChange" was changed to "onchange" etc. Please help. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">...
3
3905
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 statement? Something like this: document.forms.myDropDown.onChange = somfunc;
4
9818
by: tjonsek | last post by:
I have two drop down boxes on a form. One feeds the second a list options based on user selection. With the second drop down, I want code that displays dynamic text in a <div> based on whatever the user selects. So far, it doesn't seem to be firing. I am only testing the functionality because I have quite a bit of text to display depending on the users input and want to get it working first before I bother typing everything.
3
2420
by: itp | last post by:
I have moved to Matt Kruse's Javascript Toolbox. It has some great examples to get you going quickly! Unfortunately all the examples are based on a form/submit model. I would like to try using the onchange event ot submit a request. Has anyone tried this and could maybe provide an example? ref: http://www.ajaxtoolbox.com/about/
7
38643
by: slekshmipriya | last post by:
Hai friends.I have a pblm with my drop down list onchange event.The pblm is as follow I have a drop drown list with items 1,2 ,3 etc. On selecting an item from the drop down list i want to populate that much text boxes for entering values.for example if i select 3 , three text boxes are to be created.if 1, one text box like that. So with out reloading this page can i achieve my need?Most of the time the funtion for reloading the page is...
7
22455
controlbox
by: controlbox | last post by:
I have recently inplemented some drop-down lists (combos) on a page where one is dynamically populated according to the selection of another using the microsoft ajax extensions. I had to set AutoPostBack = true, and enable viewstate in order for the serverside events to fire, but once this was done, all seemed well - so far so good... Also, when the page form is submitted, the Javascript validateForm() function is executed to perform...
13
8735
by: andypb123 | last post by:
Hello, The onchange event fires in IE6 in a SELECT element when scrolling through the list with the up and down arrows on the keyboard. In Firefox it only fires after you hit the enter key, which is the behaviour I want make happen in IE. Does anyone know how to accomplish this? Thanks a lot Andy Birchall
1
4369
by: ruds | last post by:
Hello, I have a JSP page in which HTML form elements are present. I have a drop down list named Country, when a user selects his country I want another drop down list to populate based on the first list the names of coresponding states in that country. For this I want to retrive values from database onchange event of the first drop down list. My code is: <HTML> <HEAD>
0
8246
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8631
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8490
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7174
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1489
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.