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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:19:45+00:00 2026-05-22T17:19:45+00:00

I have a form which has a select list associated with the field players

  • 0

I have a form which has a select list associated with the field players.

To populate the listbox, user clicks on a button on the form to display a popup and from that popup select players’ names and then click another button on the popup which closes the popup and displays the selected values in the listbox.

By default, i put selected="true" in the select tag so that when user saves the form, the values in the listbox are saved.

<select size=5 id="sub_player_ids" name="sub[player_ids][]"  multiple selected="true">

The above code selects all options in the selectbox and those options are highlighted in blue.

However it can happen that user deselects an option in the player’s select box by error.

I would like all options in the select box to be selected by default – whether they are highlighted or not

Is there is a way to select all options in the select box by default when saving the form?

Thanks a lot for any suggestion provided.

Cheers

  • 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-22T17:19:46+00:00Added an answer on May 22, 2026 at 5:19 pm

    Do you know the values in the select? You can loop over the select and set each options selected to true.

    for (var i = 0, children = select.childNodes, l = children.length; i < l; i++) {
        if (children[i].tagName === "OPTION") children[i].selected = true;
    }
    

    Fiddle is using the fact that Chrome/IE7+ should define window.select as the element found in the DOM by the ID select. If you run this in Firefox you’ll need var select = document.getElementById('select');

    http://jsfiddle.net/robert/VKF4E/

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

Sidebar

Related Questions

I have written a simple CRUD form which has one select list. However the
I have this html form which has options: <tr> <td width=30 height=35><font size=3>*List:</td> <td
I have a UserForm class which has a select list populated from a related
I have a form in which the user can either select from a pre-existing
I have a form in an ASP.NET MVC project which has a select drop
I have a form to add contacts into a database, which has a select
I have a form which has a lot of SELECTs. For various reasons, I'd
I have a form which has only tab control in it. I want to
I have a form which has a Combo Box Control. I have selected the
I have WPF Form which has many buttons with the same code. Appearance of

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.