473,761 Members | 8,112 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple Multiple Select Boxes

I'm looking to have multiple multiple-select-boxes on a page. But I
can only get the contents from the last selected value within a box,
via PHP. I've tried numerous methods.
What am I doing wrong?

You can see ALL the values present in the url:
http://myserver/test.php?notify_user...updcats=Update
e.g.

Box[2]
1 aaa <-this is selected by user, but missing when processed by php.
2 bbb <-this is selected by user.
3 ccc
4 ddd

Box[4]
1 aaa
2 bbb
3 ccc <-this is selected by user.
4 ddd

Box[6]
1 aaa
2 bbb
3 ccc
4 ddd <-this is selected by user.

My code returns:
Box=2, Id=2
Box=4, Id=3
Box=6, Id=4

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Help Desk - Admin panel - Ticket options</title>
</head>
<body>
<form name="cat_list" method="get" action="test.ph p">
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<!--DWLayoutTable-->
<tr>
<td valign="top" class="content1 " style="border-width: 1px 1px 0px
0px;"><!--<input style="width: 100px;" value="{murra31 5}"></td>-->

<select name="notify_us er_id[2]" multiple size="4" style="width:
307px;">
<option selected value="1"> aaa</option>
<option selected value="2"> bbb</option>
<option value="3"> ccc</option>
<option value="4"> ddd</option>

</select>
</td>

</tr>

<tr>
<td valign="top" class="content1 " style="border-width: 1px 1px 0px
0px;"><!--<input style="width: 100px;" value="{murra31 5}"></td>-->

<select name="notify_us er_id[4]" multiple size="4" style="width:
307px;">
<option value="1"> aaa</option>
<option value="2"> bbb</option>
<option selected value="3"> ccc</option>
<option value="4"> ddd</option>

</select>
</td>
</tr>

<tr>
<td valign="top" class="content1 " style="border-width: 1px 1px 0px
0px;"><!--<input style="width: 100px;" value="{murra31 5}"></td>-->

<select name="notify_us er_id[6]" multiple size="4" style="width:
307px;">
<option value="1"> aaa</option>
<option value="2"> bbb</option>
<option value="3"> ccc</option>
<option selected value="4"> ddd</option>
</select>
</td>
<tr align="center" valign="middle" >
<td height="20" colspan="5" class="content2 "
style="border-width: 1px 0px 0px 0px;"><input name="btn_updca ts"
type="submit" id="btn_updcats " value="Update">
<input name="btn_delca ts" type="submit" id="btn_delcats "
value="Delete"> </td>
</tr>
</tr>
<table>
</form>
</body>
</html>

PHP -------------------------
<?php

if (is_array($_GET["notify_user_id "]))
{

foreach($_GET['notify_user_id '] as $id=>$col_val)
{
$aRay = array($col_val) ;
foreach($aRay as $id2=>$col_val2 )
{
echo "Box=".$id. ", Id=".$col_val2. "<br>";
}

}
}
?>

Mar 22 '06 #1
2 3108

mu*********@yah oo.com wrote:
I'm looking to have multiple multiple-select-boxes on a page. But I
can only get the contents from the last selected value within a box,
via PHP. I've tried numerous methods.
What am I doing wrong?

You can see ALL the values present in the url:
http://myserver/test.php?notify_user...updcats=Update
e.g.

Box[2]
1 aaa <-this is selected by user, but missing when processed by php.
2 bbb <-this is selected by user.
3 ccc
4 ddd

Box[4]
1 aaa
2 bbb
3 ccc <-this is selected by user.
4 ddd

Box[6]
1 aaa
2 bbb
3 ccc
4 ddd <-this is selected by user.

My code returns:
Box=2, Id=2
Box=4, Id=3
Box=6, Id=4

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Help Desk - Admin panel - Ticket options</title>
</head>
<body>
<form name="cat_list" method="get" action="test.ph p">
<table width="100%" border="0" cellpadding="0" cellspacing="0" >
<!--DWLayoutTable-->
<tr>
<td valign="top" class="content1 " style="border-width: 1px 1px 0px
0px;"><!--<input style="width: 100px;" value="{murra31 5}"></td>-->

<select name="notify_us er_id[2]" multiple size="4" style="width:
307px;">
<option selected value="1"> aaa</option>
<option selected value="2"> bbb</option>
<option value="3"> ccc</option>
<option value="4"> ddd</option>

</select>
</td>

</tr>

<tr>
<td valign="top" class="content1 " style="border-width: 1px 1px 0px
0px;"><!--<input style="width: 100px;" value="{murra31 5}"></td>-->

<select name="notify_us er_id[4]" multiple size="4" style="width:
307px;">
<option value="1"> aaa</option>
<option value="2"> bbb</option>
<option selected value="3"> ccc</option>
<option value="4"> ddd</option>

</select>
</td>
</tr>

<tr>
<td valign="top" class="content1 " style="border-width: 1px 1px 0px
0px;"><!--<input style="width: 100px;" value="{murra31 5}"></td>-->

<select name="notify_us er_id[6]" multiple size="4" style="width:
307px;">
<option value="1"> aaa</option>
<option value="2"> bbb</option>
<option value="3"> ccc</option>
<option selected value="4"> ddd</option>
</select>
</td>
<tr align="center" valign="middle" >
<td height="20" colspan="5" class="content2 "
style="border-width: 1px 0px 0px 0px;"><input name="btn_updca ts"
type="submit" id="btn_updcats " value="Update">
<input name="btn_delca ts" type="submit" id="btn_delcats "
value="Delete"> </td>
</tr>
</tr>
<table>
</form>
</body>
</html>

PHP -------------------------
<?php

if (is_array($_GET["notify_user_id "]))
{

foreach($_GET['notify_user_id '] as $id=>$col_val)
{
$aRay = array($col_val) ;
foreach($aRay as $id2=>$col_val2 )
{
echo "Box=".$id. ", Id=".$col_val2. "<br>";
}

}
}
?>


Change:

<select name="notify_us er_id[4]"

to:

<select name="notify_us er_id[4][]"

Notice the extra [] after the name. So, on the page that processes the
form, you'll have $_GET['notify_user_id '][4] and it will be an array:

foreach($_GET['notify_user_id '][4] as $notify_id) {
//do something with $notify_id
}

Mar 22 '06 #2
Thanks! ...it looks so obvious now.

Final update to the example:

<?php

if (is_array($_GET["notify_user_id "]))
{

foreach($_GET['notify_user_id '] as $id=>$col_val)
{
foreach($_GET['notify_user_id '][$id] as $notify_id)
{
echo "Box=".$id. ", Id=".$notify_id ."<br>";
}
}
}

Mar 22 '06 #3

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

Similar topics

12
8884
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
3
4319
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
3
2414
by: james.dixon | last post by:
Hi I was wondering if anyone else had had this problem before (can't find anything on the web about it). I have three select elements (list boxes - from here on I'll refer to them as 'the list boxes'). Users can add and remove items from the list boxes. When the users are adding and removing items, the list boxes are single
4
1954
by: teknoshock | last post by:
I have created a page with multiple drop down boxes, all populated with the same options. My problem is, for 12 dropdown boxes and 40 choices per box, I end up with a massive file. Also, if I want to change or add options to a drop down box, I then have to copy that to the other 11 boxes. Would it be possible to define the options once, and then have all of the drop down boxes get their options from the single list? Here is my...
6
9429
by: Dave | last post by:
On my form I have combo boxes. These combo boxes, after updating them, populate respective listboxes that are located below the combo boxes on the same form. I am trying to use a "generate report" button located on my form to print all of the list box values (that have been updated via selection from combo boxes) from the form to the report. I've tried using a macro with the code: Macro Name: cmdGenerateReport : On Click Action:...
2
5034
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation is this, I have a page which uses multiple postbacks to generate a list of dynamic text boxes with appropriate labels. However, when I do the final postback to enter the values in the dynamic textboxes into the database the values seem to become...
25
5402
by: bonneylake | last post by:
Hey Everyone, Well i am not sure if my question needs to be here or in coldfusion. If i have my question is in the wrong section i am sorry in advance an will move it to the correct section. Basically i have a multiple select box. An it works except for this one part i want to add to it.The first box i have is called project members which shows the users you can choose to send an email to and the other box is called assignees which is the...
6
4673
by: woodey2002 | last post by:
Hi Everyone. Thanks for your time. I am trying to create a search form that will allow users to select criteria from multiple multi select boxes. So far i have managed to achieve a search option for 2 list boxes:- county and nationality, while trying to add a third multi select list box for qualifications search is where i encounter my problem. I've copied the working code from my working list boxes, however it cant seem to pick up the...
1
6799
by: woodey2002 | last post by:
Hi Everyone and many thanks for your time.. I am trying to begin access and a bit of VBA i am enjoying it but I have a annoying problem I just can’t get any where on. My databse mostly includes bits of code for different examples. I have one last thing to finish. I am trying to create a search form that will allow users to select criteria from multiple sources eg ,multi select list boxes , combo boxes. I have a subform showing all the...
0
9353
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
9975
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9909
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
9788
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
8794
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...
0
5241
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3889
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
3
3481
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.