Separator in Select Menu

  • trinkel
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 69
  • Thank you received: 0

trinkel created the topic: Separator in Select Menu

Is there a proper (or more proper) way of adding a separator to a select menu list in BreezingForms? Right now I'm using:
0;----------;
And then validating with valueNotNone. However, the user can still select it. The validation catches it, but it would be nice to avoid the situation entirely.

Is there a way to have a none selectable separator in a select menu list?

Thanks!
#236370
  • Posts: 3128
  • Karma: 105
  • Thank you received: 413

mihaela replied the topic: Separator in Select Menu

Hello,

In my opinion, the best way to have a none selectable separator in a select menu list is to leave the "0;
;" option, but to write a piece of code that will disable that option so that it can't be selected.

Here are instructions on how to do so.

Please go to Advanced properties of the select list element. Scroll down and in Initscript section set Custom as Type. Furthermore, check the Form Entry checkbox. In the code below put the following code:
function ff_name_init(element, condition)
{
    switch (condition) {
        case 'formentry':
jQuery('[name="ff_nm_name[]"] option:eq(3) ').prop('disabled', 'disabled');
            break;
        default:;
    } // switch
} // ff_name_init
NOTE: In the code above you have to replace all 3 instances of name with the Name of your select list element.

This is an example that will disable the 4th option in the select list element. If you wish to disable let's say 7th option, you have to use
option:eq(6)

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

Regards,

Mihaela
#236379
  • trinkel
  • Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 69
  • Thank you received: 0

trinkel replied the topic: Separator in Select Menu

Hi Mihaela

I finally had a chance to get back to this project. Your suggestion worked great. Thank you very much!

To give back to the community . . . I ended up modifying the code some to make it a little more flexible and, believe it or not, it still seems to work. I adapted it be a library script and it disables any options that have an empty value in the list to which it is attached. The main change was the JQuery line:
function ff_disable_select_options_init(element, condition) {
	switch (condition) {
		case 'formentry':
			jQuery('[name="' + element.name + '"] option[value=""] ').prop('disabled', 'disabled');
			break;
		default:
	} // switch
} // ff_disable_select_options_init

So, for example, in the following select list, the first and fifth items would be disabled:
0;Select Group;
0;Squirts and U10;SquirtsU10|85
0;Pee Wee and U12;PeeWeeU12|85
0;Bantam and U14/HS;BantamU14HS|85
0;----------------;
0;Girls U10 and U8 (Incoming & Returning);GirlsU10U8|85
0;Girls U12 (Incoming & Returning);GirlsU12|85
0;Girls U14/HS (Incoming & Returning);GirlsU14HS|85

Thanks again for your help.
#236982
  • Posts: 3128
  • Karma: 105
  • Thank you received: 413

mihaela replied the topic: Separator in Select Menu

Hello,

Great! I'm glad that the proposed solution worked for you.

Thank you for sharing the improved solution with the community. Good job. :)

Regards,

Mihaela
#236986
Moderators: ForumSupport
Time to create page: 0.084 seconds

We Are Doing Our Part

Massive discounts on all of our extension subscription plans to help you and your business in these times.

Get Your Subscription Here

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!

News and Updates

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

All Extensions Subscription

We are doing our part and support your business with extremely low prices -- For example 6-Months-Subscription for only $9 USD. For as long as necessary.

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!