Solved

Retruve the multiple value from the select multiple tag in PHP

Posted on 2004-04-06
4
240 Views
Last Modified: 2010-04-17
Hi Experts,

    I have an html file which has a select tag with multiple selection and i want to get the selected multiple value from that html file to the php file

 html file is as follows

<html>
<body>
<select name = "option" multiple>
<option>one</option>
<option>two</option>
<option> three</option>
</select>
</body>
</html>

PHP file is as follows

<?php

    $selectvalue = $_POST['option'];

?>

but in this php file i'm getting only one value and i'm nit getting multiple value.

Please help me out to solve this .
 or give me some example that would help me out

Thanx

0
Comment
Question by:mohan21_kumar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Expert Comment

by:gourav_jain
ID: 10772489
Hi,

use @selectvalue = $_POST['option'] instead, this will give you the array of all the values of your form variable "option".

Gourav Jain
0
 
LVL 28

Accepted Solution

by:
peakpeak earned 25 total points
ID: 10772636
In the form definition you need brackets after the name to define an array

<select name="option[]" multiple>

In the php script you then extract the values as follows:

<?php
$option = $_POST['option'];
foreach($option as $selected)
{
        print $selected." / ";
}       
?>

Regards
Peter
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question