TOPIC:

Textarea auto height based on contents 10 months 3 weeks ago #237427

  • Topic Author
  • baileynp
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 76
  • Thanks: 1
Hi all

I'm putting together another form which is a questionnaire, and currently looks like:



As you can see, it consists of individual checkboxes (not a group), and text areas. The fields are populated via an SQL query at runtime.

My question is how to set the textareas' height based on the content, which as you can see is variable length.

Is there any way to do this?

Or, if not, can you suggest another way of displaying this text to the right of the checkboxes?

As ever, your humble and obedient servant. :)
Attachments:

Please Log in or Create an account to join the conversation.

Textarea auto height based on contents 10 months 3 weeks ago #237430

  • MarioPuco's Avatar
  • MarioPuco
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 5958
  • Karma: 119
  • Thanks: 554
Hi,

We don't have this feature I'm sorry :(
But I just googled around and it feels really easy to setup, so here are the steps I did :

1) example : jsfiddle.net/C8e4w/1/
2) Set your textarea height to 0 ( inside element option )
3) Go to your Initialization Script and add this code inside the function :
jQuery('#ff_elem10915').wrap('<div id="content"> </div>');

jQuery('#content').on( 'change keyup keydown paste cut', 'textarea', function (){
    jQuery(this).height(0).height(this.scrollHeight);
}).find( 'textarea' ).change();

As the example shows you need a DIV around your textarea elements so that's why I used jQuery('#ff_elem10915').wrap('<div id="content"> </div>'); and you will need to use it for all your textarea elements.

Here is a working link : mrpuco.com/index.php/radiogroup

Regards,
Mario

Please Log in or Create an account to join the conversation.

Textarea auto height based on contents 10 months 3 weeks ago #237433

  • Topic Author
  • baileynp
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 76
  • Thanks: 1
Hi - thanks for the quick response. :)

Well, it sort of works. ;)

I set the textareas' heights to 0px in form design.

I added the following code to the script that is run when a 'next' button is clicked:
// Set textarea contents
ff_getElementByName('txt_' + section + '_' + arr[i][2]).value = arr[i][4];

// Set textarea height
var txt_area_id = ff_getElementByName('txt_' + section + '_' + arr[i][2]).getAttribute("id");
jQuery('#' + txt_area_id).wrap("<div id='content'> </div>");
jQuery('#content').on( 'change keyup keydown paste cut', 'textarea', function () {
		jQuery(this).height(0).height(this.scrollHeight);
}).find( 'textarea' ).change();

... and I get this. :)



The <div> is being correctly inserted, and I've tried moving the line
// Set textarea contents
ff_getElementByName('txt_' + section + '_' + arr[i][2]).value = arr[i][4];
to after the set height part, but with the same result.

Help :)
Attachments:

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Moderators: ForumSupport
Time to create page: 0.096 seconds

July Sale!

Discounts for all of our extensions + support. Ending July 31st!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!