Textarea values to select list

  • mrperfectpz
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 101
  • Thank you received: 0

mrperfectpz created the topic: Textarea values to select list

How do I populate a select list dropdown values from values in textarea.
Also 6 must be selected and only allow max 6 ?
#239263
  • Posts: 3124
  • Karma: 104
  • Thank you received: 409

mihaela replied the topic: Textarea values to select list

Hello,

Here is how to fill a select list with lines from textarea element as options.

Go to the Advanced properties of the textarea element. In the Actionscript section set Type to "Custom" and Actions to "Change".

In the code area that appears below put the following code:
function ff_textareaname_action(element, action)
{
    jQuery("[name=\"ff_nm_selectlistName[]\"] > option").remove(); 
    jQuery("[name=\"ff_nm_selectlistName[]\"]").append("<option value=>Choose option</option>");

    var lines = jQuery("[name=\"ff_nm_textareaname[]\"]").val().split("\n"); 
    for(var i = 0;i < lines.length;i++){
        if(lines[i] != "") {
            jQuery("[name=\"ff_nm_selectlistName[]\"]").append("<option value=" + lines[i] + " >"+ lines[i] +"</option>");
        }
    }
} // ff_textareaname_action
NOTE: In the code above you have to replace every instance of "textareaname" with the actual name of the textarea element in your form.

Furthermore, replace each instance of "selectlistName" with the name of the select list in your form which you wish to fill with options.

Let me know whether you have managed to apply this to your form and whether this is working as you wanted.

As for allowing users to select max and only 6, do you mean that this select list will have the "Multiple" checkbox checked so that users can select more than one option and the number of selected options has to be 6?

Regards,

Mihaela
#239294
  • mrperfectpz
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 101
  • Thank you received: 0

mrperfectpz replied the topic: Textarea values to select list

I did as you mentioned but is not working :(

Also, yes I need "Multiple" so can select more than one and has to be 6
#239305
  • Posts: 3124
  • Karma: 104
  • Thank you received: 409

mihaela replied the topic: Textarea values to select list

Hello again,

Can you please send me the code you are using so I can try to find a reason why it is not working for you?

I have tested this code on an example form and for me, it is working properly.

Regards,

Mihaela
#239310
  • mrperfectpz
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 101
  • Thank you received: 0

mrperfectpz replied the topic: Textarea values to select list

Hi Again Michaela

Here is the code

function ff_PlayerNames_action(element, action)
{
jQuery("[name=\"ff_nm_JoinPlayerSelect[]\"] > option").remove();
jQuery("[name=\"ff_nm_JoinPlayerSelect[]\"]").append("<option value=>Choose option</option>");

var lines = jQuery("[name=\"ff_nm_PlayerNames[]\"]").val().split("\n");
for(var i = 0;i < lines.length;i++){
if(lines != "") {
jQuery("[name=\"ff_nm_JoinPlayerSelect[]\"]").append("<option value=" + lines + " >"+ lines +"</option>");
}
}
} // ff_PlayerNames_action
#239317
  • mrperfectpz
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 101
  • Thank you received: 0

mrperfectpz replied the topic: Textarea values to select list

I have set up a test form with textarea and select list and called them the same as your code and copied your code, placed it in action for textarea and it still doesnt work. I thought it may have been a problem with my form but this proves not. I hope you can work it out.
#239383
Moderators: ForumSupporttomeperica
Time to create page: 0.071 seconds

New Icon Packs Category!

Crosstec is now offering icon packs.

If you are a paying subscriber, icon packs are automatically added to your account.

Check out our icon packs page!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Summer Sale!

50% discount on all of our extension subscription plans, templates and icon packs!

Get Your Subscription Here

News and Updates

Get informed about new downloads, updates and more in our News and Updates newsletter.

All Extensions Subscription

Get 1 year access to all of our current and future products and 1 year of professional support -- 99 for just 49! (Summer Sale)

No support per domain or website installation limits! Includes all of our current and future Joomla!® extensions, Joomla!® templates for the duration of your membership. This means, by purchasing an All Extensions Subscription you'll have it all covered!

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!

Live Support Chat Opened!

Join our Discord chat here to receive live support and talk directly to the team!

Community Reward

Help us to create new extensions and plugins! With only $5 you help us a lot and get unlimited download access to all of our products, professional support and even more. Get your reward now!

Read More Here