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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:22:37+00:00 2026-05-26T01:22:37+00:00

I have a button which opens a popup window and lets me to choose

  • 0

I have a button which opens a popup window and lets me to choose something from a list and then returns to parent page with the ID and NAME variables. In the parent page, I store ID in an hidden field and NAME in a textbox.
This is ok when i choose one thing from list. But now I want to choose multiple things and store ID’s and NAME’s in a listbox value and text property.
How can I do that?
These are the javascript codes I am using for textbox and hidden field.

<script type="text/javascript">
  function get_selected_machine(ID, NAME) {
      document.getElementById("txtName").value = NAME;
      document.getElementById("hdnID").value = ID;
    }
</script>
  • 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-26T01:22:37+00:00Added an answer on May 26, 2026 at 1:22 am

    Below is a very simple example that illustrates how to get the values from a listbox using pure JavaScript. How you decide to store the values on the client once you have them is up to you.

    HTML:

    <select id="multiSelect" size="5" multiple="multiple">
        <option value="o1">Option 1</option>
        <option value="o2">Option 2</option>
        <option value="o3">Option 3</option>
        <option value="o4">Option 4</option>
        <option value="o5">Option 5</option>
        <option value="o6">Option 6</option>
    </select>
    <br />
    <button id="btnGetValues" onclick="GetValues()">Get Values</button>
    

    JavaScript

    function GetValues() {
        //Get select object
        var myList = document.getElementById("multiSelect");
    
        //Create array to store selected values
        var aryMySelectOptions = new Array();
    
        //Loop through all values and grab selected
        for (var i = 0; i < myList.options.length; i++) {
            if (myList.options[i].selected) {
                aryMySelectOptions.push(new selectOption(myList.options[i].innerText, myList.options[i].value));
            }
        }
    
        //Loop through selected values and alert for debugging purposes
        for (var i = 0; i < aryMySelectOptions.length; i++) {
            alert("Text: " + aryMySelectOptions[i].text + ". Value: " + aryMySelectOptions[i].value + ".");
        }
    }
    
    function selectOption(text, value) {
        var text;
        var value;
    
        this.text = text;
        this.value = value;
    }
    

    Here’s a working jsFiddle.

    Note: The jsFiddle uses jQuery, but only as a means of attaching to the click event of the button. I did not use jQuery for anything else because I’m assuming that you want a pure JS solutions (you didn’t tag jQuery in your post).

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

Sidebar

Related Questions

I have noticed on the E-Gold page a small button called SRK which opens
I have a web page with a button that opens up a popup page
I have a div which opens when I click a menu button, I am
I have UserControl which contains a TextBox and a Button control. The Button opens
I have button, which fires an event, that deletes a record from the database.
I have one sharepoint custom page application which is rendering from a user control.
Creating a popup window from main page with window.open, the child/popup page uses the
I have GridView which I can select a row. I then have a button
Presently I have a button which will open a popup and it also pass
I have an html page. On that page I want to open popup window.

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.