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

How to change WIDTH of empty SELECT box with no dynamic elements added

JJA
I would like to know how to expand the width of SELECT boxes with
Javascript. These have the MULTIPLE attribute and a SIZE attribute
greater than 1 (usually around 10 or so).

The OPTION elements are dynamically constructed from database content.

I've observed that the overall width of the SELECT element seems to be
equal to the width of the entry with the most text.

How can set the width with Javascript?

When I have no entries, the box looks strangely narrow.
Jul 23 '05 #1
2 12232

"JJA" <jo***@cbmiweb.com> schrieb im Newsbeitrag
news:2c************************@posting.google.com ...
How can set the width with Javascript?


Assuming that you have a form with name="myform" and a sellect with
name=myselect", you can do this with document.myform.myselect.style.width,
e. g. you could ask:
if (document.myform.myselect.length == 0)
document.myform.myselect.style.width = "100px";

Hope this helps you.

Nice greetings from
Thomas
Jul 23 '05 #2
Ivo
"JJA" wrote
I would like to know how to expand the width of SELECT boxes with
Javascript. These have the MULTIPLE attribute and a SIZE attribute
greater than 1 (usually around 10 or so).
Strange. In my observation 4 to 6 seems to be the most favourite size.
I've observed that the overall width of the SELECT element seems to be
equal to the width of the entry with the most text.
How can set the width with Javascript?
You create a reference to the select element, by means of its name or
document.getElementsByTagName('select')[index_number] and then set the width
attribute of its style object. For example:

myselectreference.style.width='10em';

In CSS it is even easier, and it even works with javascript off:

<select style="width:10em;"></select>
When I have no entries, the box looks strangely narrow.


Then there should no select element at all, I would think, but instead a
message explaining its absence.
--
Ivo
Jul 23 '05 #3

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

Similar topics

23
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
2
by: RWD | last post by:
I am trying to figure out how to change the target frame in my hyperlink on a DHTML menu. The menu is in one frame and the target frame is called "main" The code is below: Thanks in advance...
4
by: mike eli | last post by:
Hi, I have several absolute positioned elements inside an absolute positioned DIV. I would like one of the nested elements to have a dynamic width. I set it's left and right attributes to 5, so...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
13
by: Gary | last post by:
I have a table with a form consisting of several checkboxes and I'm wondering if its possible to change the table row background color on mouseover or hover and make it stay that color when the...
1
by: NullBock | last post by:
Hi, I'm trying to create a form with a text-input (not textarea) that expands to the size available, using CSS. I thought that a simple display:block would work: <form> <div> <input...
6
by: Aaron Smith | last post by:
Ok. I have a dataset that has multiple tables in it. In one of the child tables, I have a column that I added to the DataSet (Not in the DataSource). This column does not need to be stored in the...
5
by: Bubba | last post by:
I have a dynamic pulldown list (ASP with javascript) that when a user picks a state, the corresponding counties for that state appear in a dynamic second pulldown list. When I submit the form, the...
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...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
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...
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...

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.