optgroup in select
-
Hi!
I need to make optgroup in select in form, and i found the decision, it seems everything is correct but it doesn’t work:
source: https://www.gilluminate.com/2011/08/08/using-jquery-to-enable-optgroup-in-cforms/
In header.php:
<script type="text/javascript"> if($(".cform").length!=0){ $(".cform select option").each(function(){ if($(this).val() == "groupstart"){ var label = $(this).text(); $(this).nextUntil('option[value|="groupend"]') .wrapAll("<optgroup label='"+label+"' />"); $(this).detach(); } }); $('option[value|="groupend"]').detach(); } </script>
Once you have that code in place, all you need to do is add groupstart and groupend codes to your cforms settings for your select box. For the groupstart you will add it as though it were just another option, with the label being the label you want for your group, and the value being the literal string “groupstart.” For the groupend, it doesn’t matter what the label is, as long as the value is “groupend.” It’s easiest just to use groupend as the label, and leaving the value empty so that CForms will automatically use the label as the value.
and in form:
Color#Choose#Warm Colors|groupstart#red#orange#yellow#|groupend#Cool Colors|groupstart#blue#green#purple#|groupend#brown#black#white
It should be like this:
https://www.gilluminate.com/wp-content/uploads/optgroup-cforms.png
But i get this:
https://oi67.tinypic.com/wjeyk0.jpg
https://oi64.tinypic.com/5mhleg.jpgWHY IT DOESNT WORK?
- The topic ‘optgroup in select’ is closed to new replies.