admin管理员组

文章数量:1415145

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic.

Closed 10 years ago.

Improve this question

I am using contact-form-7 plugin for one of my form in the site. In that I have some dropdown options. The option are mainly consists of some come courses with their names. Like course 1, course 2, course 3, course 4....so on. But I want that my course field should be seen like this

Course A:

  course 1
  course 2
  course 3
  course 4

Course B:

  course 1
  course 2
  course 3

Course C:

  course 1
  course 2

Course D:

  course 1
  course 2
  course 3

Currently I have done this type of fields in my contact-form-7 plugin Course applied for[select courser-applied class:course-applied "Course A" "course 1" "course 2" "course 3" "course 4" "Course B:" "course 1" "course 2" "course 3" "Course C:" "course 1" "course 2" "Course D:" "course 1" "course 2" "course3"] But this one is not working as I want that course A,course B, course C, course D should come in strong character in dropdowns . So can someone kindly tell me how to do this? Here how I want my form dropdown should look like

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic.

Closed 10 years ago.

Improve this question

I am using contact-form-7 plugin for one of my form in the site. In that I have some dropdown options. The option are mainly consists of some come courses with their names. Like course 1, course 2, course 3, course 4....so on. But I want that my course field should be seen like this

Course A:

  course 1
  course 2
  course 3
  course 4

Course B:

  course 1
  course 2
  course 3

Course C:

  course 1
  course 2

Course D:

  course 1
  course 2
  course 3

Currently I have done this type of fields in my contact-form-7 plugin Course applied for[select courser-applied class:course-applied "Course A" "course 1" "course 2" "course 3" "course 4" "Course B:" "course 1" "course 2" "course 3" "Course C:" "course 1" "course 2" "Course D:" "course 1" "course 2" "course3"] But this one is not working as I want that course A,course B, course C, course D should come in strong character in dropdowns . So can someone kindly tell me how to do this? Here how I want my form dropdown should look like

Share Improve this question edited Aug 26, 2019 at 8:51 Glorfindel 6093 gold badges10 silver badges18 bronze badges asked Oct 24, 2013 at 10:08 NewUserNewUser 1812 gold badges3 silver badges15 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 2

-- Append parent_ to all your top level options' values like: parent_Course A, parent_Course B -- Also add extra options with the value as "endparent" something like below structure

parent_Course A:
  course 1
  course 2
  course 3
  course 4
endparent
parent_Course B:
  course 1
  course 2
  course 3
endparent

Code:

// contact us form - change out optgroup labels
$(function() {
    // search for parent_ items
    var foundin = $('option:contains("parent_")');
    $.each(foundin, function(value) {
         var updated = $(this).val().replace("parent_","");
        // find all following elements until endparent
        $(this).nextUntil('option:contains("endparent")')
        .wrapAll('<optgroup label="'+ updated +'"></optgroup');
    });
    // remove placeholder options
    $('option:contains("parent_")').remove();
    $('option:contains("endparent")').remove();
});

本文标签: pluginsWordpress contact form 7 to show the form dropdown menus as like