KB Article 15991
2019/01/24

Close
X
Contact Tech Support

 Email Tech Support
 (250) 655-1766
 [7:30 - 5:00 PST]
Your Meeting ID will be Provided by a Rep.
Tech Support
Tech Support Home
Software Updates
Knowledge Base Search
Recent KB Articles
Product FAQs
Code Samples
Documentation
Tech Blog
System Requirements
Installation Instructions
Support Testimonials
Contact us to...
Create a Ticket
Request a Free Demo
Suggest a New Feature
Submit Feedback
Upload a Large File
Other Services
Software Training
Professional Services

Make an input width vary with the length of the text

Product: Presto Type: How to

How can I make an input resize to help fit the content as I type?

There are many ways one can do this with some javascript. The easiest way to implement it in Presto would be to add the following code to the onkeypress event for the element in the Visual Editor:

this.style.width =((this.value.length + 1)*10)+ 'px';

A couple caveats:

- If you have retain spaces on then there is whitespace in the input which will give it an initial size (you may want to consider giving it an minWidth if it's too small to start with as well).

- A lot of elements will have a maxlength attribute too (to integrate better with the underlying greenscreen app) which will still place an upper bound on the element size.

Further Resources:

https://stackoverflow.com/questions/3392493/adjust-width-of-input-field-to-its-input 

Rate This Article

Did this example help you to achieve your goal?
 Yes  No  Don't Know

Enter additional comments below.   If you want to hear back from us, include your contact information.

Email Address:
Comments:
Please enable JavaScript in order to rate this page.