Yeah, this is the behavior of select lists.  What comes through in the form
post is the item that was last selected.  

What I've found you have to do with javascript is populate a hidden field
with the values, using some delimiter (I've used commas) and you can easily
explode those values into an array in the processing script.

In your form have an onsubmit like this:

onSubmit="SetList2Values(this.yourlist,this.list2values)"

(change list2values to the hidden field you define for this purpose.

Here's the javascript function list2values I use:

echo "function SetList2Values(box,list2values)  {\n";
echo "var t = \"\";";
echo "for(var i=0; i<box.options.length; i++) {\n";
echo "if(box.options[i].value != \"\") {\n";
echo "t = t + box.options[i].value + \",\";\n";
echo "      }\n";
echo "   }\n";
echo "list2values.value = t;";
echo "return true;}\n";

echo "// End -->\n";
echo "</script>\n";


In the post script I have:

$rListvalues = explode(",", $_POST['list2values']);

foreach through that and do your processing.

-----Original Message-----
From: Micah Montoy [mailto:[EMAIL PROTECTED] 
Sent: Saturday, July 05, 2003 3:56 PM
To: [EMAIL PROTECTED]
Subject: [PHP] looping through values from a field? Need hellp.


1.  Choose a file  <input type="file" name="viewing" onchange="loadImg();">
2. File location and name are displayed in the
<select name="imgList" style="width:350;" size="6" multiple></select> as
<option value="c:\images\filename.gif">c:\images\filename.gif</option>
The javascript creates the option and a new option is added and appended
when a new file is chosen.
3. Submit form to php script to send location and stuff to database.

Anyone have any ideas of how I can get PHP to loop through and pull out each
option value?  They are separated by a comma.  Right now, it only grabs the
last file even though all files are highlighted before submission.




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

Reply via email to