tags:

views:

32

answers:

3

hi Is there any way through which we can get all the selected values in a list box?

+2  A: 

do you mean

<select name="foo" MULTIPLE>       
  <option value="bar1" >Option 1</option> 
  <option value="bar2" >Option 2</option> 
  <option value="bar3" >Option 3</option> 
</select>

so that the end user can select multiple items in a form?

A: 

Ignore Post

you can delete it, by clicking `delete` link.
SilentGhost
A: 

If you're using PHP, you can give the select an array-style name:

<select name="items[]" multiple>
  <option value="option-1">Option 1</option>
  <option value="option-2">Option 2</option>
  <option value="option-3">Option 3</option>
</select>

Accessing these values from the server-side is rather simple:

<?php

  foreach ($_POST["items"] as $value) {
    echo $value . "<br/>";
  }

?>
Jonathan Sampson