• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

dynamic size for input box

 
Chris O'Neill
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have an input box which needs to be able to change in size depending on the number of characters that are fed into it when the page is loaded. Is there a way of setting the size="" parameter to take in a dynamic variable equal to the length of the figure fed into it?

At the moment it just renders at a fixed size and that doesn't accomodate to my design wishes.

Thanks
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Are we talking about HTML or about a Java Swing GUI?
 
Chris O'Neill
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It's on a HTML page.

<input type="text" size="?var?" etc..>
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, cool. We have a forum for HTML and Javascript here. I'm going to move this topic there, and I'm sure someone will be able to give you a good answer.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this what you want:



The size of the textbox will change depending on the length of the string 'someString'
[ July 25, 2006: Message edited by: jaikiran pai ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The thing is setting a length of a string to the size of a textbox will still be wrong. type in a bunch of i or spaces or w and see what happens.

You will see you are not going to get a good fit, but it will work just fine.

Eric
 
Chris O'Neill
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes that does the job.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic