How to select a field in Jquery’s $ui.dropdown

Asked

Viewed 26 times

0

Guys all good??

I wanted to leave some fields already selected through an id’s that I’ll bring from php.

with these id’s I would like to compare with the id’s already written in the sector field "those that are hidden" and the id’s that are equal, would be displayed within the field.

"as if someone was chosen such sector".

Obs: in this dropdowm to select more than one field.

Not without how to do it, thanks for your attention.

<script>
            $(document).ready(function () {

                $('.ui.dropdown').dropdown(
                            fields: {
                            remoteValues: 'results',
                            values: 'values',
                            name: 'name',   // displayed dropdown text
                            value: 'value'   // actual dropdown value
                        }
                    }
                );

            });

</script>


           <select name="alcada[]" id="setor" multiple="" class="ui fluid search dropdown">
                            <?
                            foreach ($hashSetor as $setor) {
                                if ($setor['setorID'] == $hashEdit['alcada']) {
                                    $selected = 'selected';
                                } else {
                                    $selected = '';
                                }
                                ?>
                                <option value="<?=$setor['setorID']?>"><?=$setor['nome']?></option>
                            <? } ?>
                        </select>

Campo de seleção

  • Hey, buddy, here’s a better explanation because you can’t figure out where you’re going with this. You are a little confused and with spelling mistakes that make it very difficult to understand. By the way, you can’t even understand. Abs!

  • Sorry, I already edited the text.

  • Have you tried putting the $selected in the option: <option <?=$selected?> value="<?=$setor?>"><?=$setor?></option>?

  • There is no logic to this, I will simply put the option ...and not set it..

  • What’s happening here... is that I selected a user in a list and the system put their information in the page’s <inputs> fields so that I can edit these infomations. only that I have to specify in this sector field which sectors it belongs to.

  • So... if you put the options as Selected do not appear listed the sectors coming from PHP?

  • Um.. maybe but maybe bad because I’m already printing on "foreach" ...but you gave me an idea.

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.