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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:42:40+00:00 2026-06-11T06:42:40+00:00

I have the following select box on a form with an unknown number of

  • 0

I have the following select box on a form with an unknown number of options:

<select>
   <option value="v1">v1</option>
   <option value="v2">va2</option>
   <option value="v3">va3</option>
   <option value="v11">v11</option>
   <option value="v12">va12</option>
   <option value="v13">va13</option>
</select>​

I have the following array defined in javascript:

var checkValArray = ['v1', 'v2', 'v13'];

What I would like to do is go through every option of the select box and see whether an element of my array is equal to it.

What would be the best way to put this into practice?

Your help is highly appreciated.

  • 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-11T06:42:41+00:00Added an answer on June 11, 2026 at 6:42 am

    There’s a very useful jQuery API method: $.inArray. So it should be something like this:

    var optionValue = $('select option:selected').val();
    if ($.inArray(optionValue, checkValArray) !== -1) {
      // it's in
    }
    else {
      // it's not
    }
    

    For multiselects it may be used with something like…

    $('select option:selected').each(function() {
       if ($.inArray(this.value, checkValArray) !== -1) { ... }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following multi-select box in a HTML form, where user can select
I have the following drop down box in a form for rails: <%= f.select
I have the following code: <select name=to class=combo value=' <?php if(isset($_POST['reply'])) { echo <option
I have the following code on a view: @using (Html.BeginForm()) { <div class=select-box form>
I have the following select box in my form: Related Type: &nbsp; <%= f.select(:TYPE,
I have the following multi select box in a HTML form: <select multiple=multiple name=fruits>
I have the following code to retain the value of a select box, which
I have the following dropdown box <form name=myform method=POST ACTION=songs.php> Select Category: <select id=sel
I have a form with a select box whose options are pre selected by
I have the following part of my form: <input type=checkbox class=hide id=additional-webinar name=additional-webinar-check value=additional-webinar-box>

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.