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 7625531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:12:17+00:00 2026-05-31T05:12:17+00:00

I have a problem with the multi-select box. I tried to select multiple values

  • 0

I have a problem with the multi-select box. I tried to select multiple values using jQuery, but only the last one is selected, can anyone help me please? Here is my code:

<script>
$(function(){
 <?php 
 foreach ($selectdefaults as $s):
   ?>   
   $('#q<?php echo $s['campsetjoin']['campid'];?> select').val('<?php echo $s['campsetjoin']['setid'];?>');
   <?php  
 endforeach;
 ?> 
});
</script>

Here is my HTML source (this is generated with PHP):

<table>
<tr>
    <td>
        <form id="s1" name="camps">
            <input type="hidden" name="camid" value="1" />
            <strong> Camp 1 </strong>
        </form>
    </td>
    <td align="right" id="q1">
        <select name="qsets" multiple="multiple">
            <option value="1">common set</option>
            <option value="2">test set</option>
        </select>
    </td>
    <td>
        <input type="button" value="update" cid="1" class="btncdsave" />
    </td>
</tr>
<tr>
    <td>
        <form id="s9" name="camps">
            <input type="hidden" name="camid" value="9" />
            <strong> Camp 2 </strong>
        </form>
    </td>
    <td align="right" id="q9">
        <select name="qsets" multiple="multiple">
            <option value="1">common set</option>
            <option value="2">test set</option>
        </select>
    </td>
    <td>
        <input type="button" value="update" cid="9" class="btncdsave" />
    </td>
</tr>
<tr>
    <td>
        <form id="s10" name="camps">
            <input type="hidden" name="camid" value="10" />
            <strong> Camp 3 </strong>
        </form>
    </td>
    <td align="right" id="q10">
        <select name="qsets" multiple="multiple">
            <option value="1">common set</option>
            <option value="2">test set</option>
        </select>
    </td>
    <td>
        <input type="button" value="update" cid="10" class="btncdsave" />
    </td>
</tr>
</table>

So I need to select multiple values of the select box. I can get the form id and select box value ids for selection. Thanks for you help.

  • 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-05-31T05:12:18+00:00Added an answer on May 31, 2026 at 5:12 am

    If you want to select multiple values, pass an array with those values

     $('#q10 select').val(['1', '2']);
    

    fiddle here http://jsfiddle.net/p8R4k/

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

Sidebar

Related Questions

I have the following problem using a has_many :through many-to-many relation in a multi-select
I’m working on a multi dimensions array but i have a problem Imagine I
I have a multi-dimensional array, no problem. How do I interrogator one of the
Since including <mvc:annotation-driven/> I have experienced a problem when binding the selections of multi-select
I have a multi-select listbox in a SL3 app using prism and I need
I have a situation where I want to associate multiple values from one table
I have a TStringGrid where the selected row (max 1, no multi-select) should always
I have been using the following code (with jQuery v1.4.2) to set the 'selected'
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have a form that (amongst other things) contains 2 multi-select listboxes. Basically you

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.