Textarea values to select list

  • Posts: 3119
  • Karma: 104
  • Thank you received: 409

mihaela replied the topic: Textarea values to select list

Hello again,

I see now that you have errors in your code, you haven't copied it properly.

Please try to use the following code and let me know whether it works:
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[i] != "") {
            jQuery("[name=\"ff_nm_JoinPlayerSelect[]\"]").append("<option value=" + lines[i] + " >"+ lines[i] +"</option>");
        }
    }
} // ff_textareaname_action

The main error is that you have been using
lines
instead of
lines[i]

Let me know whether this worked.

Regards,

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

mrperfectpz replied the topic: Textarea values to select list

No, sorry this doesnt work
#239403
  • Posts: 3119
  • Karma: 104
  • Thank you received: 409

mihaela replied the topic: Textarea values to select list

Hello again,

Just to check, have you defined at least ONE option in the select list from the start.

This can, for example, be:
0;Choose option;

It is important that you have at least one option defined in the list otherwise the select list element won't be shown at all.

Regards,

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

mrperfectpz replied the topic: Textarea values to select list

seems to work fine now on creating a record, doesnt like it in edit
#239420
  • mrperfectpz
  • Topic Author
  • Offline
  • Expert Boarder
  • Expert Boarder
  • Posts: 101
  • Thank you received: 0

mrperfectpz replied the topic: Textarea values to select list

Ok, I put the code in the form Initialization Script and it all works great, thankyou !!!!
Going back to my other question.....

Select list will allow users to select more than one option and the number of selected options has to be 6?
#239430
  • Posts: 3119
  • Karma: 104
  • Thank you received: 409

mihaela replied the topic: Textarea values to select list

Hello again,

I am glad that this solution is working as you wanted when you put it in the Initialization script.

Regarding selecting 6 options, would it be ok for you for this to be implemented as a validation script?

That way, if the number of selected options exceeds 6, they will get an error message saying to select fewer options and they won't be able to submit the form unless they do so.

Go to Properties of the select list element and in Validation section set Type to Custom.
In the code area that appears put the following code:
function ff_selectlistname_validation(element, message)
{
    var num = jQuery('[name="ff_nm_selectlistname[]"] option:selected').length;
   
    if (num > 6) {
        if (message=='') message = element.name+" faild in my test.\n"
        ff_validationFocus(element.name);
        return message;
    } // if
    return '';
} // ff_selectlistname_validation
NOTE: In the code above replace "selectlistname" with the actual name of the select list element.

Let me know whether this is working as you wanted.

Regards,

Mihaela
#239441
Moderators: ForumSupporttomeperica
Time to create page: 0.076 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