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

  • Home
  • SEARCH
  • 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 105857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:30:19+00:00 2026-05-11T01:30:19+00:00

I have a listbox on an HTML form with a Submit button. The listbox

  • 0

I have a listbox on an HTML form with a Submit button. The listbox has multiple selection enabled. I am able to select multiple values in the listbox, but I don’t know how to figure out what values were selected when the form is submitted. Also, I am adding user generated values to the list box dynamically using JavaScript, and I would like to be able to tell two things when the form submits:

  1. What are the options added to the box by the user?
  2. What values are selected in the box by the user?

Is this possible? Thanks.

  • 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. 2026-05-11T01:30:19+00:00Added an answer on May 11, 2026 at 1:30 am

    Below you find an example of a page.

    Note that:

    • the select element (and any form element) needs a name to be included in the post.
    • only selected options in the select element will be posted.

    What values are selected in the box by the user?

    When the user submits the form only the selected values will be sent to the server. Depending on what language you are using at the server there are different ways to access them.

    What are the options added to the box by the user?

    As stated before you only see what options that was selected. But how do you distinguish between your options and the users options? That depends on what data you are sending the user. The universal answer is thats the value you get back that you didn’t send. However this can be simplified depending on your data. Since the options have both a value and a text property, one way it to use a numeric value for your pregenerated values. That way your values will be numeric in the reply and the users values will be a text string. This approach assumes that your user will not enter just a numeric value. Another approach is to add a prefix to all user generated values (remember you have both a value and a text field for all options)

    <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> <html xmlns='http://www.w3.org/1999/xhtml'>   <head>     <title>Test of select box</title>     <script type='text/javascript'>       function addOpt(e) {         var o=document.createElement('option');         //o.value= -e.options.length;         o.text = 'Test ' + e.options.length;         o.selected=true;         e.add(o,null);       }     </script>   </head>   <body>     <form method='post' action='mypage.html'>       <input type='button' onclick='addOpt(this.form.myselect)' value='Add option'/>       <br/>       <select id='myselect' name='mydata' multiple='multiple' size='10'>         <option value='0'>Test 0</option>         <option value='1'>Test 1</option>         <option value='2'>Test 2</option>       </select>       <br/>       <input type='submit'/>     </form>   </body> </html> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 139k
  • Answers 139k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This seems to work: def attach(w,c1,c2,r1,r2): eb = gtk.EventBox() a… May 12, 2026 at 7:43 am
  • Editorial Team
    Editorial Team added an answer Arguments against: Frameworks prevent you from re-inventing the wheel Frameworks… May 12, 2026 at 7:43 am
  • Editorial Team
    Editorial Team added an answer I think this is a similar dilemma some of my… May 12, 2026 at 7:43 am

Related Questions

I have a page which has an Html.DropDownList which takes in a viewdata parameter.
How can I display a preview (almost like a hint) of an image when
This error message is driving me nuts. I'm getting it when using Html.ListBox and
I have a property file( actually 100 or more). This is actually placed in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.