473,395 Members | 1,379 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.

Select dropdown

Hi,
is there a possibility to change the size of the select-dropdown-box ?
I predefine the length of the option-area with 10 inside HTML as
follows:

<select class="select250" name="projectTypeSelect">
<script language="JavaScript"
type="text/javascript">document.lopForm.projectTypeSelect.opt ions.length=10;</script>
</select>

The resulting dropdown-box will be 10 rows long.

If I have less entries, let's say 4, there will be 6 empty rows and I
want to shorten
the dopdownbox to 4 rows.

Anyone knowing a way to do this ?

Thanks
Wolfgang

Dec 14 '06 #1
2 1812
Wolfgang wrote:
Hi,
is there a possibility to change the size of the select-dropdown-box ?
I predefine the length of the option-area with 10 inside HTML as
follows:

<select class="select250" name="projectTypeSelect">
<script language="JavaScript"
type="text/javascript">document.lopForm.projectTypeSelect.opt ions.length=10;</script>
</select>

The resulting dropdown-box will be 10 rows long.

If I have less entries, let's say 4, there will be 6 empty rows and I
want to shorten
the dopdownbox to 4 rows.

Anyone knowing a way to do this ?
Hi,

You can simply find all individual options inside a SELECT via:
document.formname.selectname.options.
It will return an array with Option objects in them.
on each Option you can get the text and value.

In your case you can remove the options that contain no text or no value.
You can remove an option by setting the value to null (in the array that
contains the options).

But I wonder why you add 10 options in the first place...
Why not just add what you need?

Regards,
Erwin Moller
>
Thanks
Wolfgang
Dec 14 '06 #2
ASM
Wolfgang a écrit :
Hi,
is there a possibility to change the size of the select-dropdown-box ?
I predefine the length of the option-area with 10 inside HTML as
follows:
why not to have a dropdown of 0 option (length = 0)
and increase it step by step ?
var S = document.lopForm.projectTypeSelect.options;
S.length = 0;
for(var i=0; i<4; i++)
{
var o = new Option('text '+i, 'val '+i);
S[S.length] = o;
}


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 14 '06 #3

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

Similar topics

2
by: Jas | last post by:
I want an ASP page with a dropdown and a simple button. Every time the user chooses an item from the dropdown and clicks on the button i want that value written below in list and allow user to...
1
by: Rod Early | last post by:
I need to know when the select element's dropdown list is opened (as when the user clicks on the arrow or does ALT-downarrow from the keyboard). Similarly, I need to known when the dropdown list...
5
by: Ganco | last post by:
We have a dropdown combobox, where some of the text is wider than the textarea. I cannot set the width of the SELECT any higher due to design restrictions on the company website. When clicking...
9
by: Prowler | last post by:
In our current application we have a page whose sole purpose for existence is to permit the user to select from a list (subsequent to our login page). We would like to have the list drop down...
6
by: passion_to_be_free | last post by:
This is probably simple, but I can't seem to find it anywhere. I have have some values stored in javascript variables. I have a <select> dropdown list whose options correspond to these values. I...
2
by: hypomite | last post by:
I have an handler for the SelectedIndexChanged event of a dropdown box. I have also set the AutoPostBack option to True. When you select any item besides the first one, the event sucessfully fires....
5
by: balu435 | last post by:
Hi friends, I have an (VBA) application which programatically fills the options in a web page. I have an dropdown menu whose options are selected during run-time by using a function.Is there...
4
by: =?Utf-8?B?c2lMdmVy?= | last post by:
Hhi, I'm working on an asp .net project that have small side panel which 'disallow' long SELECT/dropdown list.. So i could not force them to a certain that shows my longest option, which now...
1
by: RichardR | last post by:
I have a webpage which has a table that contains a column with several drop down boxes (<SELECT>). The contents of the drop down boxes are dynamically populated so I have no idea what the actually...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
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
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...

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.