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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:16:58+00:00 2026-06-08T07:16:58+00:00

i am fetching all the values from select element, which will not have selected

  • 0

i am fetching all the values from select element, which will not have selected attribute using this piece of jquery code.

$('#purchaseEditUpdateItemBtn').on('click', function(){
    var selected = [];
    $('#box2View option').each(function(index, element){ 
        selected[index] = $(element).val(); 
    });
    return false;
});

here is my select box.

 <select id="box2View" multiple="multiple" class="multiple">
     <option value="1">ITEM001</option>
     <option value="2">ITEM002</option>
     <option value="3">ITEM003</option>
     <option value="4">ITEM004</option>
 </select>

this will create a javascript array named selected and hold the values as an array.i want to fetch all the values from option and emulate the query like this.

estimate_id[]=1&estimate_id[]=2&estimate_id[]=3&estimate_id[]=4

so that it is received by server side as an array.

P.S: please note that, i want to fetch all the elements from select elements without user selecting any, so for the reason, selected attribute is not used. i tried using serialize() which didn’t work because serialize() requires the elements to be selected, which cannot be true in my case.

thank you

  • 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-08T07:17:01+00:00Added an answer on June 8, 2026 at 7:17 am

    You could try something like this:

    $('#purchaseEditUpdateItemBtn').click(function(){
        var selected = [];
        $('#box2View option').each(function(index, element){ 
            selected[index] = 'estimate_id[]=' + $(element).val(); 
        });
        alert(selected.join('&')); 
        return false;
    });​
    

    Not sure if this is the most elegant way. It uses simple string concatenation via the Array.join function.

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

Sidebar

Related Questions

I am fetching all records from a db table into a page using; SELECT
I have two tables tracklist and song. I am fetching all values from song
I have prepared few queries using startwith and connectby for fetching all items of
i have following code in which, i am fetching the data from the sqlite
I have a problem fetching values from a MySQL cursor. I create a temporary
I have a LINQ query which is fetching a list of nested objects. from
So I have the following code for fetching all of my core data entities
I'm fetching data from all 3 tables at once to avoid network latency. Fetching
Now a lot of scripts to facebook-style fetching data from url, but all of
I am fetching some data from a site using its API-key and some other

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.