Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
How to display the selected values correctly in bootstrap dropdown function?

I am using bootstrap to create select multiple function. Now my problem is I want to follow my selected value to show in the select multiple function, but it cannot work. Below is my problem coding:

<select id="jabatan_edit" name="jabatan_edit" title="Jabatan" class="form-control">
    <?php
    $sql_jabatan = 'SELECT * FROM jabatan where is_active=?';
    
    $types[] = 'i';
    $values[] = 1;
            $row_jabatan = base_mysqli_select($sql_connection, $sql_jabatan, $types, $values);
            foreach ($row_jabatan as $val_jabatan) {
                $jabatan = "1,3";
                $check_jabatan = $val_jabatan['id'];
                $jabatan_value = explode(',',$jabatan);
                    if (in_array($check_jabatan, $jabatan_value ))
                      {
                      $selected_jabatan = 'selected="true"';
                      }
                    else
                      {
                      $selected_jabatan = 'selected="false"';
                      }
                 echo '<option value="' . $val_jabatan['id'] . '" ' . $selected_jabatan . '>' . $val_jabatan['kod_jabatan'] . '</option>';
            }
            
    unset($types);
    unset($values);
    ?>
</select>

This is my javascript function:

$('#jabatan_edit').multiselect({
        nonSelectedText: 'Pilih ahli-ahli',
        enableFiltering: true,
        enableCaseInsensitiveFiltering: true,
        buttonWidth:'100%'
        });

My output is shown me like below the picture, the result just can show $jabatan value = 3:

a1

May I know how to display the selected values correctly? For example I want the actual result like below can show $jabatan value = 1,3:

o1

Hope someone can guide me on how to solve this problem. Thanks.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!