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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE7 option elements in a drop down limit?

Status
Not open for further replies.

rvuj

Programmer
Mar 11, 2009
3
US
Hi all,

After an update that I have received on my laptop for IE7 on last week, i see an issue with the drop downs in the application that I am supporting. Here is the description of this.

If I select any option after 250322 options, it is not returning the selected index value. It is simply giving me the error message that "this object doesnt support this property or method". This code has worked fine until before I have applied the upgrade. Is it because there is any limit on the options that a drop down can display?

Here is the code snippet where I am getting this error.

var obj=document.getElementById(listBoxID);
var tempText=obj.options[obj.selectedIndex].text;
listboxid is a variable.

Any suggestions on this will be greatly appreciated?
 
I'm not sure about getting around the limit while still using a regular select element... but how about using some sort of intelligent DHTML/AJAX select element replacement that filters the box depending on what you have typed?

You will benefit 2 ways:

1. Your users will not have to wait for all the data to load in one go, and

2. Your users won't have to wade through over 250,000 items in a select list (which is quite excessive, I think)

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
BillyRay,

I was going to say something similar, but thought I'd let someone who has been on these boards a little longer say it first...

My response wouldn't have been so nice - but here it is anyway...

rvuj --> why on earth would you have a drop down list with over 200,000 entries? Must be a nightmare for your users to go through a list that long to select a single value.

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Hi Bill N Vick,

This is a old application that was written by some one. I am just supporting it.

This is part of type ahead feature that is provided in the application. Also, it is not possible to rewrite this because of the budget constraints.

Thanks for the AJAX alternative, but customer is not willing for this.

So, I need the fix but not alternative.

Do you heard of any such limitations in dropdown?
 
I tried this with a drop down list containing 260,000 elements, selected the last one and it worked...maybe what you are looking for...

Also, I used a different approach to getting the selected index - you may be able to work it in with your's. The key was converting the selectedIndex to a float.

Code:
<script>
function show() {
	var selValue = parseFloat(document.getElementById("ddl").selectedIndex);
	alert(selValue);
}
</script>

<select id="ddl">
<option value="1">Value 1</option>
<option value="2">Value 2</option>
<option value="3">Value 3</option>
...
<option value="260000">Value 260000</option>
</select>
<input type="button" name="btn" value="show selected index" onClick="show();" />

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Hey Viv,

Thanks for the suggestion. Even with this approach, its stopping exactly at the option count of 312499. Sorry I was wrong last time abt the count. I miscalculated it.

Any other ideas?
 
nope, sorry I can't help, don't want to sound like a jerk but a drop down list with over 200,000 values is just wrong (as you know and have agreed), adding another 100,000+ values to bring that count to over 300,000 boggles my mind...

My advice to you is to take BillyRay's advice and split it up somehow - I don't know what kind of data is in the drop down, but let's say it's numbers 1 - 300,000.

Build a second drop down that asks the user to select a range: (1 - 99999, 100000 - 1999999, 200000+) and then populate the second drop down accordingly.

Again, I don't know what kind of data you have and how it is sorted, but you could probably resolve the problem within a half hour or so and less than 20 lines of code.

Good luck :)

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
ok, so I'm back...

I ran this script on a drop down list containing 400,000 elements, selected the last one and clicked the button - it worked, returned 399999...

Maybe it's the machine's the users are on, I got a pretty good one, but it was very slow in loading the page - the page itself was over 22MEGS, and I was running it locally - can't imagine what it's like over a network to download it...

Code:
<script language="javascript">
function showIDX() {
	var ddl = document.getElementById("ddlList");
	alert(ddl.selectedIndex);
	}
</script>
<input type="button" value="Show Selected Index" onClick="showIDX()"><Br />
<select id="ddlList">	
	<option value="opt_1">Option 1</option>
	<option value="opt_2">Option 2</option>
	<option value="opt_3">Option 3</option>
	<option value="opt_4">Option 4</option>
	...
	<option value="opt_400000">Option 400000</option>
</select>

TIP: trying googling the answer before posting, you'll find that more times than not someone else somewhere has had the same request and posted an answer online.
----
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javascript enabled browsers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top