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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:12:52+00:00 2026-05-12T05:12:52+00:00

How can i have three or more select tags with same names(as in my

  • 0

How can i have three or more select tags with same names(as in my program, the select tags are being generated dynamically), and select independently what option was selected.
I have a loop, where my php reads a sql table, and for each row, it creats a select tag and a button with it.

<select name="vote">
    <option value="1">1</vote>
    <option value="2">2</vote>
    <option value="3">3</vote>
</select>

<input type="button" onclick="vote()">

So suppose i have 3 rows in my sql table, so 3 select tags with buttons would be created.

Now my question is how can i see what select tag has what option seleted??

Can anyone help me with this.

Zeeshan

  • 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-12T05:12:53+00:00Added an answer on May 12, 2026 at 5:12 am

    When you have multiple elements in a form with identical name attributes, they become a collection (essentially, an array) in the DOM.

    So where you might have one select like this

    <form name="test">
      <select name="example"></select>
    </form>
    

    You would access the select element like so

    document.forms.test.example;
    

    Now, if you had 2 or more, like this

    <form name="test">
      <select name="example"></select>
      <select name="example"></select>
      <select name="example"></select>
    </form>
    

    You would access them in the DOM like this

    document.forms.test.example[0];
    document.forms.test.example[1];
    document.forms.test.example[2];
    

    EDIT

    Oh, on the PHP end, it won’t recognize multiple values unless you add [] to the name – this tells PHP to not replace same-key-name values, but rather use them as an array.

    <form name="test">
      <select name="example[]"></select>
      <select name="example[]"></select>
      <select name="example[]"></select>
    </form>
    

    Then, you would read these values like so

    <?php
    
    $exampleArray = $_GET['example'];
    // you can now loop over $exampleArray or whatever.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Table1 and Table2 related on Table1.ID. There can be zero or more
I have three values I need to align in a dropdown box. How can
I have three applications that talk to each other using sockets. They can all
Well here's my problem I have three tables; regions, countries, states. Countries can be
In one of my iPhone projects, I have three views that you can move
I have a UserControl that consists of three TextBoxes. On a form I can
I have a system where employees can upload files. There are three ways Upload
Good morning, folks. I have a question here. I have three select. Brings first
I want to have a tree in memory, where each node can have multiple
I have a binary tree where each node can have a value. I want

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.