• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

HTML - is there a 'maxlength' for select boxes?

Question

Rail Grinder    127

as the topic states, is there a way to limit the length of a select box the same way you can limit the length of an input box either thru css or javascript?

i'm trying to make a <select> tag "fit" inside a table cell but one of the values in the select box is too and it ends up stretching out the width of the cell. i came by this:

http://www.devguru.com/Features/tutorials/...mbocontrol.html

but it uses vb script and i want something to be compatible across a variety of platforms. can someone help me out?

thanks in advanced :)

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0
OSUKid7    0

Yes, this?

&lt;input type="text" maxlength="14" /&gt;

Share this post


Link to post
Share on other sites
  • 0
)-(orus    2

The link, after a quick scan, replaces the code for a standard drop down, with various form elements, divs and images. I have worked on something like this myself using a combination of html, css and javascript, but its still a work in progress.

The objective of this link seems to be to overcome the styling limitations of a combobox, i.e. comboboxes inherit most of their appearence from the operating system, and always have the highest z-index(s) on the page, so any floating divs used will appear below a combobox, regardless of any positioning you set.

I think all you are looking for is:

Using the style attribute of the <select> tag, set "width:[desired width];" if you want the select box to inherit the entire width of the cell you might try style="width:100%;" in the <select> tag.

Share this post


Link to post
Share on other sites
  • 0
Rail Grinder    127
Yes, this?

&lt;input type="text" maxlength="14" /&gt;

585871032[/snapback]

hehee that's the first thing i tried and it doesn't work. but thanks for the reply :)

Using the style attribute of the <select> tag, set "width:[desired width];"  if you want the select box to inherit the entire width of the cell you might try style="width:100%;" in the <select> tag.

585871054[/snapback]

thank you sir! that did the trick :D

this thread can now be locked/closed/deleted

Share this post


Link to post
Share on other sites
  • 0
Rail Grinder    127
this thread can now be locked/closed/deleted

585873837[/snapback]

ok so i've got another question ... i found some css styles that can be used with the <style> tag and i tried using the word-wrap style as stated here:

http://msdn.microsoft.com/library/default....ects/select.asp

needless to say it doesn't wrap. anyone got any suggestions? sorry for these n00bish questions. i used the following code in my <style> tag within my <header> tags:

&lt;style&gt;
select {word-wrap : break-word}
&lt;/style&gt;

Share this post


Link to post
Share on other sites
  • 0
)-(orus    2

I think your asking if you can make the content of a select box span over 2 lines!?!

If you are then you can't, that simple, sorry.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.