aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes dynamic size for input box Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "dynamic size for input box" Watch "dynamic size for input box" New topic
Author

dynamic size for input box

Chris O'Neill
Greenhorn

Joined: Jul 24, 2006
Posts: 4
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

Joined: Jul 08, 2003
Posts: 24166
    
  30

Hi,

Welcome to JavaRanch!

Are we talking about HTML or about a Java Swing GUI?


[Jess in Action][AskingGoodQuestions]
Chris O'Neill
Greenhorn

Joined: Jul 24, 2006
Posts: 4
Hi,

It's on a HTML page.

<input type="text" size="?var?" etc..>
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

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

Joined: Jul 20, 2005
Posts: 9318
    
109

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 ]

[My Blog] [JavaRanch Journal]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
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

Joined: Jul 24, 2006
Posts: 4
yes that does the job.

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: dynamic size for input box
 
Similar Threads
how to get textbox value into action class
getting a column to hug its contents
getParameter returns truncated string
Javascript Manipulation of Struts SELECT
Netscape - Input Boxes