PDA

Click to See Complete Forum and Search --> : DropDown menu


parkes
Feb 2nd, 2001, 09:04 AM
Does anyone know if its possible to set the width of a dropdown menu on an ASP page.

Cander
Feb 2nd, 2001, 09:29 AM
Dont think there is. Its always as wide as your longest item.

nickclarkson
Feb 2nd, 2001, 10:42 AM
There is a way - I found it by accident.

I tried everything, and I couldn't find a way to set the width of a drop down box; I tried setting the width of the form, the width of the <select> tag, the width of the <option> tags. Nothing. Then I just-for-the-hell-of-it thought try CSS. So I created a one-line CSS file;

select {width : 450 }

and saved it as build.css (the name was relevant to the project I was doing)

then added the following line in the <HEAD> section of the file with the drop down boxes that needed formatting;

<LINK REL="StyleSheet" TYPE="text/css" REF="build.css">

And voila, it worked ! Now, I don't know if all browsers will format this properly, especially Netscape, but I know it works in IE 5+.

If you want to see a working example and download some very basic code done in about a minute goto
http://www.nickclarkson.co.uk/dropdown.html
In the example I created a subclass called alternative to demonstrate how easy it is to change the width. If you need any more information on CSS try http://www.w3schools.com/css - it's a really good site.

(Oh and the site is new, so there's not a lot there ;)

Nick Clarkson

abdul
Feb 2nd, 2001, 03:59 PM
Hi now i got the answer!
use the style sheet in the select tag like this:


<select style="width: 344px">
</select>


The width is 344 pixels. You can make it as wider as you can.

This one should work!!!!!!

nickclarkson
Feb 2nd, 2001, 06:28 PM
Abdul,

You mean a bit like I said in my post about 12 hours ago ?

abdul
Feb 2nd, 2001, 06:44 PM
Sorry guy!
Actually I did not look at your code. I already knew that becasue I used Ms Script program.

parkes
Feb 5th, 2001, 03:25 AM
Thanks everyone that sorted it