RE: [PHP] getting values from multiple select

2002-03-14 Thread Ford, Mike [LSS]

 -Original Message-
 From: Scott St. John [mailto:[EMAIL PROTECTED]]
 Sent: 13 March 2002 21:32
 
 I am working on a javascript box that will allow the user to 
 drag values 
 from one select box to another.  I will use this box to set 
 the values.
 This is a standard, multiple select box.  On the next page I need to 
 figure out what PHP is doing with the data coming in.
 
 If I send 5 fields to the next page PHP will show me one when 
 I echo the 
 variable to the page.

Name your field with trailing brackets (e.g. INPUT NAME=field_name[] ...) and you 
will see it as an array in PHP containing your 5 (or however many) values.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] getting values from multiple select

2002-03-14 Thread Erik Price


On Wednesday, March 13, 2002, at 04:31  PM, Scott St. John wrote:

 If I send 5 fields to the next page PHP will show me one when I echo the
 variable to the page.  If I try to split the varaiable I still get only
 one value in the echo.  Tried to reponse.write it in asp and I get the
 string with comma seperate values.

Did you try putting brackets at the end of the input names?  This tells 
PHP to put the values into an array, whose key is the name of the input.

select name=choice[] multiple=yes
   option value=aA/option
   option value=bB/option
   option value=cC/option
/select

This might work for you,


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] getting values from multiple select

2002-03-14 Thread Scott St. John

Yes, I have tried that.  To view them on the next page I would call
them as $choice[0];$choice[1];, etc, but only the first item in the list 
is available.

-Scott


On Thu, 14 Mar 2002, Erik Price wrote:
 Did you try putting brackets at the end of the input names?  This tells 
 PHP to put the values into an array, whose key is the name of the input.
 
 select name=choice[] multiple=yes
option value=aA/option
option value=bB/option
option value=cC/option
 /select
 
 This might work for you,
 
 
 Erik
 
 
 
 
 
 
 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]
 

-- 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] getting values from multiple select

2002-03-14 Thread Erik Price


On Thursday, March 14, 2002, at 09:33  AM, Scott St. John wrote:

 Yes, I have tried that.  To view them on the next page I would call
 them as $choice[0];$choice[1];, etc, but only the first item in the list
 is available.

Hm... have you tried using a loop to get their values, rather than using 
the numeric indexes?  Like this:

foreach ($choice as $array_element) {
   echo $array_element;
}

This will go through the entire array, regardless of numeric index, and 
echo the value of each element in the array.  Try this, if it doesn't 
work then perhaps only one value is being passed to the receiving script.

Have you made sure your listbox features the attribute

multiple=yes

and have you made sure to select more than one item in the listbox by 
holding down either Alt (PC) or Cmd (Mac) as you make your selections.  
If you're only selecting ONE item, then only one item will be passed to 
the receiving script.

Use the above techniques to make sure that you are actually passing more 
than one value.


Erik






Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] getting values from multiple select

2002-03-14 Thread Scott St. John

Ok, how about a code snipet since I seem to be blind this morning.  The 
select box code:

select multiple=yes name=groups id=av
? 
$sql = select groupID,groupName from groups order by groupName;
$result = mssql_query($sql,$connection);
while($row = mssql_fetch_array($result)){
 $groupID = $row[groupID];
 $groupName = $row[groupName];
echo option value=\$groupID\$groupName/option;
}
?
/select

On the next page I tried the code Erik recommended doing this:

foreach ($groups as $group_list){
echo $group_list;
}

Any eye openers?  Thanks,

-Scott



On Thu, 14 Mar 2002, Erik Price wrote:
 Hm... have you tried using a loop to get their values, rather than using 
 the numeric indexes?  Like this:
 
 foreach ($choice as $array_element) {
echo $array_element;
 }



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] getting values from multiple select

2002-03-14 Thread Erik Price


On Thursday, March 14, 2002, at 09:52  AM, Scott St. John wrote:

 Ok, how about a code snipet since I seem to be blind this morning.  The
 select box code:

 select multiple=yes name=groups id=av
 ?
 $sql = select groupID,groupName from groups order by groupName;


...


 Any eye openers?  Thanks,

 -Scott


Sure!  First go get a cup of coffee!  :)
Then change the first line to say this:

select multiple=yes name=groups[] id=av

Let me know how that works for you.


Erik




Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] getting values from multiple select

2002-03-14 Thread Scott St. John

On Thu, 14 Mar 2002, Erik Price wrote:
 Sure!  First go get a cup of coffee!  :)
 Then change the first line to say this:
 select multiple=yes name=groups[] id=av
 Let me know how that works for you.

Erik-

I don't do coffee, but the Iced Tea works just as well :)  Thank you, all 
is well and my happy face is back on.  I was missing the [], I had tried 
that before but had an error because I forgot to update my javascript 
code.

Thanks everyone,

-Scott



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] getting values from multiple select

2002-03-13 Thread Scott St. John

Hi gang-

I am working on a javascript box that will allow the user to drag values 
from one select box to another.  I will use this box to set the values.
This is a standard, multiple select box.  On the next page I need to 
figure out what PHP is doing with the data coming in.

If I send 5 fields to the next page PHP will show me one when I echo the 
variable to the page.  If I try to split the varaiable I still get only 
one value in the echo.  Tried to reponse.write it in asp and I get the 
string with comma seperate values.

Help!

Thanks,

-Scott


-- 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php