Note that there are some explanatory texts on larger screens.

plurals
  1. POChange size of all text areas at the same time
    primarykey
    data
    text
    <p>I currently have a function that increases the height of a text area when a user clicks inside the text area. It increases so the user can view all the contents inside the text area. It works fine currently. But I only managed to make it work one text area at a time. I'd like to change it so that ALL text areas increase at the same time whenever one of them is clicked. If anyone can give me an idea I would appreciate it.</p> <p><strong>Current HTML</strong> </p> <pre><code>&lt;textarea name="xaxis1" id="xaxis1_id" rows="3" cols="20"&gt;report facture credit impot&lt;/textarea&gt; &lt;textarea name="yaxis1" id="yaxis1_id" rows="3" cols="20"&gt;200 123 231 431&lt;/textarea&gt; &lt;textarea name="yaxis2" id="yaxis2_id" rows="3" cols="20"&gt;431 111 666 991&lt;/textarea&gt; </code></pre> <p><strong>Current JavaScript Code</strong></p> <pre><code>$('#xaxis1_id').click(function() { resizeTextArea($('#xaxis1_id')); }); $('#yaxis1_id').keydown(function(e) { resizeTextArea($('#yaxis1_id')); }); $('#yaxis2_id').click(function() { resizeTextArea($('#yaxis2_id')); }); function resizeTextArea(currentTextArea) { var textAreaElements = currentTextArea.val().split('\n'); var b=1; var totalColumns = currentTextArea.attr('cols'); for (x=0;x &lt; textAreaElements.length; x++) { if (textAreaElements[x].length &gt;= totalColumns) b+= Math.floor(textAreaElements[x].length/totalColumns); } b+= textAreaElements.length; var totalRows = currentTextArea.attr('rows'); currentTextArea.attr('rows', b); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload