• 0

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


Question

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 :)

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

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.

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

  • 0
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;

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.