Change textbox to textarea on click

How do I convert a simple text box to text area when the user clicks on it. I'm using EXT JS.

Are you doing it just for visual appearance? Or is there a valid reason for converting it from input to textarea?

If you are doing it just for the visuals of it you can get a long way with just setting the height of your textarea and in the focus event increase the height.


    new Ext.form.TextArea({
        renderTo: Ext.getBody(),
        name: 'myTextArea',
        width: 200,
        height: 22,
        listeners: {
            focus: function(textarea){
            blur: function(textarea){


EDIT: These stopped working:

Try it here:

You can even quite easily animate it for some extra fancy visualy fancy pancy.

Can you change a text input to textarea?, Is it possible to change a text field to a textarea while entering data and then have it revert back to a text field once the user tabs of clicks outside� Adds an event listener to a <textarea> which executes JavaScript scripting when an onchange event occurs. Code Example <form> <textarea onchange="alert('You just changed the textarea.')" placeholder="Type in this box. When you click away an alert will be generated."> </textarea> </form>

You can't change a textbox to a textarea because they are two different types of elements. You can however hide one and display the other.

<input type='text' id='myTextBox' />
<textarea id='myTextArea' />

With some function that could swap them on whatever event you want:

function swapTexts() {
    var tb = document.getElementById('myTextBox');
    var ta = document.getElementById('myTextArea');
    if ( !== 'none') { = 'none'; = '';
    } else { = ''; = 'none';

Dynamically change textbox to textarea? (HTML Pages with CSS , Insert the textarea element into the DOM after the text box. text2textarea(this) function, when I click on button its creating textbox but unable to� Get Input Content. Your Entered Content is: The above example showing the input box with the button. You have to just enter any text in the textbox and click the ‘Get Input Content‘ button. The entered text content prints out in the output. Get Textarea Value with jQuery. Textarea is the input text field where you can enter multiple line

show and hide is nice technic. but., u can use innerHTML property also like this...

<div id='test'> <input type="text" name="text1" id="text1" onclick="test()"/></div>

<script type="text/javascript">
function test()
    document.getElementById('test').innerHTML = "<textarea></textarea>"

if u want to change again, give some condition or any event.. this may help u i think..

have a good day.....

Forms and Form Fields :: Eloquent JavaScript, Multiline text fields have their own tag, <textarea> , mostly because using an attribute to specify Whenever the value of a form field changes, it fires a " change" event. When a suggestion is clicked, replace the text field's current value with it. I want to know how can store the text value of TextArea and pass it to the Onclick function event. first change your button to TextBox values from View to

You can have two separate controls of TextBox and TextArea in the same div (or table) and then show the TextArea on click of TextBox

<input type='text' onclick='document.getElementById("txtArId").style.display = ""' />
<TextArea id='txtArId' />

How to Add Text to a Textarea or Text Field, How to add or replace text to a text field or textarea using JavaScript. Enter your text here, then click the button. Add to Existing Text Replace Existing Text� By default, <input> and <textarea> elements don’t change size based on the content they contain. In fact, there isn’t any simple HTML or CSS way to make them do that. Kinda funny, as that seems like a reasonable use-c

Here's an example done in jQuery.


        <input name="textInputComment" type="text" value="">
        <textarea name="textAreaComment" style="display: none;"></textarea>



         $(document).on('focusin', 'input[name=textInputComment]', function () {
              textarea = $(this).closest('tr').find('textarea[name=textAreaComment]');
    $(this).val());//show, focus and get value from input

         $(document).on('focusout', 'textarea[name=textAreaComment]', function () {
              textarea = $(this).closest('tr').find('input[name=textInputComment]');
    $(this).val());//get value from textarea

jQuery, This method works only on the “<input>, <textarea> and <select>” elements. Syntax : click on this button and see the change -->. Use a <form> element to add HTML forms to the web page for the user input. Add two <input> elements to define fields for the user input. With the first <input> use the type and placeholder attributes. With the second <input> besides these attributes, also use a class name.

After clicking outside of the input box: Example-2: In this example, alert box appears saying that ‘Text content changed!’ when either of activity happens. text of the input changed. keyup event happens. Something is pasted to the input box. propertychange occurs.

For radiobuttons and checkboxes, the onchange event occurs when the checked state has been changed. Tip: This event is similar to the oninput event. The difference is that the oninput event occurs immediately after the value of an element has changed, while onchange occurs when the element loses focus, after the content has been changed.

Text box click event removing data Selecting all the data of inside textarea by clicking Default value by using OnFocus event of a text box OnBlur:Showing help text by using onfocus and onBlur event triggers Counting the characters dynamically inside a textarea and setting a limit Copying a set of textbox entered data to another area of a form

  • @TimCoker yes it seems the external extjs libraries and css files are no longer hosted where they used to be ...
  • may i know this one fullfills your needs r not..?