473,395 Members | 1,756 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,395 software developers and data experts.

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("showRange");
}
</script>
<SELECT NAME="range" SIZE="1" onchange="showRange();">
<OPTION VALUE="0">address 1</OPTION>
</SELECT>
Jul 23 '05 #1
2 4200
"Matt" <jr********@hotmail.com> wrote in message
news:ba**************************@posting.google.c om...
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("showRange");
}
</script>
<SELECT NAME="range" SIZE="1" onchange="showRange();">
<OPTION VALUE="0">address 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("showRange");
}
</script>
<SELECT NAME="range" SIZE="1" onchange="showRange();">
<OPTION VALUE="0">address 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*****@agricoreunited.com>
comp.lang.javascript 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
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...
4
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...
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: 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...
3
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...
7
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...
7
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...
13
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.