Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7965627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:12:48+00:00 2026-06-04T06:12:48+00:00

I have been trying this for a good while now but I can’t seem

  • 0

I have been trying this for a good while now but I can’t seem to add more options to the multiselect.

Even when I try to add a hardcoded piece of information it just doesn’t get added. (The headers for Multiselect and JQuery are in a different file).

You can see the link in action here:
http://www.fakegaming.eu/GoT/index.php?act=selectteam&matchid=3

<?php
$matches = new Matches();
$user = new User();
$id = $_GET['matchid'];
$matchinfo = $matches->getmatch($id);
$matchplayers = $matches->getmatchplayers($id);
?>
<script type="text/javascript">
    $(function(){
        $.localise('ui-multiselect', {/*language: 'en',*/ path: 'script/locale/'});
        $(".multiselect").multiselect();

        $("#add").click(function() {
          $('#players').multiselect('addOptions', 'Test=123');
          alert("Handler for .click() called.");
        });
    });
</script>
Kies hier 10 spelers die mee doen aan de match.<br /> <br />

<form action='index.php?act=createteam' method='post'>
    <select id="players" class="multiselect" multiple="multiple" name="players[]">
    <?php
        foreach($matchplayers as $matchplayer){
            $userinfo = $user->getuserbyid($matchplayer['user_id']);
            if($matchplayer['type'] == 0 OR $matchplayer['type'] == 2){
                $name = $userinfo['EU_username'];
                ?>
                <option value="<?= $name ?>"><?= $name ?></option>
                <?php
            }
        }

    ?>
    </select>
    <input name='name' type='text' id='name' />
    <input type='button' id="add" name="add" value="Toevoegen" />
    <input name="submit" value="Maak team" type="submit" />
</form>

I’m probably just doing something horribly wrong but I just want a good multiselect and add some names to it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:12:49+00:00Added an answer on June 4, 2026 at 6:12 am

    You say are using jQuery, but I see very little use of it… Here would be a “jQuery way” of adding an <OPTION> to your multiselect

    $('#players').append($('<option></option>').attr('value', '123').text('345'));
    

    To select an attribute :

    $('#players option[value="123"]').attr('selected', true);
    

    to deselect an attribute :

    $('#players option[value="123"]').removeAttr('selected');
    

    to remove an option

    $('#players option[value="123"]').remove();
    

    ** Edit **

    (I didn’t look at your reference link. I should be the best to anwser, I’m one of the original authors of this widget!)

    There is a next version of this widget that Michael Aufreiter and I worked on that implements more functionality that you require. It is a little unstable with some configurations, but should be stable enough with basic (default) setup.

    You can find it here and you can access values via the options :

     $('#players').multiselect('addOptions', '123=456'); // value=123, text=456
    

    Sorry, the API documentation was not updated to document this. This widget is actually being supported by other contributors and either of us, original authors, maintain this version.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying this for a while now and can't get it to
I have been trying to get this android service working but I can not
I have been trying to wrap my head around this for a while now
Good evening, I have been trying to wrap my head about this, below, code
I have been trying this for a little while nut just cannot get to
I have been trying to get this to work with several tutorials/answers here, but
I've been trying to work with templates for a while now and the more
This has probably been asked before, but I can't find a good way of
I've been searching the web for a while now and still can't seem to
I've been trying to do this for some time now but nothing worked. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.