You are viewing limited content. For full access, please sign in.

Question

Question

optgroup in drop-down menu

asked on May 4, 2018

Has anyone implemented optgroup to a drop-down menu? I tried the following JavaScript but it seems off when I see it in the browser

 

$( document ).ready(function() {
  
$('select').prepend('<optgroup label="Some Title">');
  $("select").find("option").eq(0).remove();
  
  //$('select').append('</optgroup>');
  
});

 

optgroup.png
optgroup.png (4.02 KB)
0 0

Replies

replied on May 4, 2018

I'm thinking in creating a simple Custom HTML field and adding the HTML necessary, and then just passing the value to a hidden field that can later be stored or something. What do you think? Any other ideas?

$( document ).ready(function() {
  
  $(document).on('change blur', 'select', updateoptgroupBox);
  
  function updateoptgroupBox() {
    
    var optgroupBox = $('select').val()
    
    $('.optgroupBox input').val(optgroupBox);
    
    
  }
    
  
});

 

HTML.PNG
HTML.PNG (21.02 KB)
0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.