473,668 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting multiple data from <select>

Can anyone give me a quick hint for this?

Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>

Then I'd like to list the items selected...
echo $_POST["opt3"];
but this gives only the first one

how do I get the rest?

Feb 6 '07 #1
5 2469
"Sonnich" <so************ @elektrobit.com kirjoitti
viestissä:11*** *************** ***@s48g2000cws .googlegroups.c om...
Can anyone give me a quick hint for this?
Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>
Then I'd like to list the items selected...
echo $_POST["opt3"];
but this gives only the first one
how do I get the rest?

<SELECT NAME="opt3()" SIZE="15" multiple>

Parenthesis is the point: NAME="opt3()"

Then php knows than an array is coming. This is not because html would
require that, but because php does. This applies not only to select
elements, but checkboxes as well for example. Or sometimes you may want to
send some array in hidden fields.

Feb 6 '07 #2
On Feb 6, 4:36 pm, "P Pulkkinen"
<perttu.POISTAT AMA.pulkki...@P OISTATAMA.elisa net.fiwrote:
"Sonnich" <sonnich.jen... @elektrobit.com kirjoitti
viestissä:11707 72126.596200.67 ...@s48g2000cws .googlegroups.c om...
Can anyone give me a quick hint for this?
Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>
Then I'd like to list the items selected...
echo $_POST["opt3"];
but this gives only the first one
how do I get the rest?

<SELECT NAME="opt3()" SIZE="15" multiple>

Parenthesis is the point: NAME="opt3()"

Then php knows than an array is coming. This is not because html would
require that, but because php does. This applies not only to select
elements, but checkboxes as well for example. Or sometimes you may want to
send some array in hidden fields.
eeehhh I tried to play a bit around with this, but do I also need a
trick to read it out?

BR
Sonnich

Feb 6 '07 #3

"Sonnich" <so************ @elektrobit.com wrote

"eeehhh I tried to play a bit around with this, but do I also need a
trick to read it out?"

Well, you need to loop through the array:

foreach ($opt3 as $key =$val)
{
echo "<p>".htmlspeci alchars($key)." =".htmlspecialc hars($val)."</p>n";
}

That's something for ONE-dimensional array, though. Remember, no parenthesis anymore.
Feb 6 '07 #4
Rik
Sonnich <so************ @elektrobit.com wrote:
On Feb 6, 4:36 pm, "P Pulkkinen"
<perttu.POISTAT AMA.pulkki...@P OISTATAMA.elisa net.fiwrote:
>"Sonnich" <sonnich.jen... @elektrobit.com kirjoitti
viestissä:1170 772126.596200.6 7...@s48g2000cw s.googlegroups. com...
Can anyone give me a quick hint for this?
Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>
Then I'd like to list the items selected...
echo $_POST["opt3"];
but this gives only the first one
how do I get the rest?

<SELECT NAME="opt3()" SIZE="15" multiple>

Parenthesis is the point: NAME="opt3()"

Then php knows than an array is coming. This is not because html would
require that, but because php does. This applies not only to select
elements, but checkboxes as well for example. Or sometimes you may want
to
send some array in hidden fields.

eeehhh I tried to play a bit around with this, but do I also need a
trick to read it out?

Well, don't use () in the name, but []...

A little hint for debugging POSTs: echo file_get_conten ts('php://input')
will give you the raw input.

Example:
------------------
POST:
<?php
var_dump($_POST );
?>
INPUT:
<?php
echo file_get_conten ts('php://input');
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="check()" multiple>
<option>optio n 1</option>
<option>optio n 2</option>
<option>optio n 3</option>
<option>optio n 4</option>
<option>optio n 5</option>
<option>optio n 6</option>
</select>
<select name="check2[]" multiple>
<option>optio n q</option>
<option>optio n e</option>
<option>optio n r</option>
<option>optio n t</option>
<option>optio n y</option>
<option>optio n u</option>
</select>
<input type="submit">
</form>
------------------
--
Rik Wasmus
Feb 6 '07 #5

"Rik" <lu************ @hotmail.comwro te
Well, don't use () in the name, but []...
Oops, thanks for correction.
Feb 6 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3817
by: Andrea | last post by:
Hi, I'm trying to emulate part of our client-server application as a web site so customers can use it, and I'm stuck when it comes to re-ordering items in a list. Basically we have a list of available articles ("availableItems") and a list of articles already in an issue ("selectedItems"). What I want is to be able to move articles freely between the two lists and then on submission add them to the issue (which I can), but also move...
1
3444
by: Burton Figg | last post by:
I have a SELECT statement which holds a list of times (for adding appointments to a database): e.g. <select name="time" id="time" size="3" multiple> <option value="00:00">00:00</option> <option value="00:30">00:30</option> <option value="01:00">01:00</option> <option value="01:30">01:30</option>
1
2393
by: Ang Talunin | last post by:
Hey, I wondering if it's possible to retrieve all the <option>-fields from a <select> when posting a <form> to a php file Example: I've got a form like this: <form action = phpfile.php method=post > <select name= "name">
7
7895
by: Felix Natter | last post by:
hi, I have a php-Script which gets passed a Boat-ID and this is used to mark an element in a <select> as the default: <select name="boote" multiple="multiple" size="5"> <option value='43'>Aisha</option> <option value='40'>Amsterdam</option> <option value='55'>Asmaa</option> <option value='20'>Beau Rivage</option> <option value='48'>Blue Perl</option>
6
2398
by: Bonge Boo! | last post by:
This has got to be obvious, but I can't make it work. I have a form called with 3 pull down menus. They are linked to a database which generates the values for the <SELECT? Pull-downs. Lets say I have values selected for all three pull down menus. When I change the first "top-level" menu I want to reset both the second and third menus to the "default" state.
4
2125
by: joiv | last post by:
I'm making a <select></select> with lots of <option></option>. It contains all possible options. Because of the length of the list, I also have an <input type="text">. This is what I wish to do: onKeyDown I want all options that don't contain (or begin with, it doesn't matter which one) the typed letters to be removed from the <select>. My problem is that I don't know of any code to find words and identify
5
8305
by: Brian Foley | last post by:
Hello, I am used to using the label tag with check boxes and radio buttons in html forms. This allows me to click on the text of the label to activate/deactivate the check box / button, rather than having to click on the (possibly small) box or button. I recently tried to assign a label to a select "drop down list", but found that when I clicked on the label text to bring it into focus, the select box was reset to the first entry. ...
4
3581
by: luftikus143 | last post by:
Hi there, I have a nasty little problem, as so often, only with IE. Here is an screenshot to better illustrate the problem. http://geodata.grid.unep.ch/screenshot13.png The map is clickable (to enable zoom in and other functions). But in this case, I would like to select a value from the drop-down list, which displays as a "drop-up" list because of not having enough space downwards. Now, when I click to select a year, IE interprets this...
4
39362
by: Man-wai Chang | last post by:
-- iTech Consulting Co., Ltd. Expert of ePOS solutions Website: http://www.itech.com.hk (IE only) Tel: (852)2325 3883 Fax: (852)2325 8288
0
8462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8381
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8893
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8583
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8656
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7401
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4380
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2791
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.