> I have a <select multiple></select> object named list[] that is
> its
> selected contents to an array. That part works fine. I can use a for
> to
> grab all of the selected items. Where I'm stuck is that I want to get
> the value AND the text for any given <option> element and simply
> the items in the array 1-N based on the number of rows is not
> Example:
> <select name="itemList[]" multiple>
>       <option value="101">PHP For Dummies</option>
>       <option value="102">PHP For Professionals</option>
>       <option value="103">PHP For Gurus</option>
> </select>
> I want to be able to be able to get both the value property (101, 102,
> ...)
> AND the text between the <option></option> tags. Currently, I'm only
> getting
> the text between the <option></option> tags. Is there a PHP function
> allows me to get to both?

No, you only get the value="" part. I think your confused, or this isn't
the correct code, when you say your are getting what's between
<option></option> then you're doing something different.

Bottom line, you only get the value part. If you want two values passed,
then use some hidden elements to relate the values.

<input type="hidden" name="itemListtext[101]" value="PHP For Dummies">

would relate to your first element. So in PHP, you'd have

$_POST['itemList'][0] == 101
$_POST['itemListtext'][$_GET['itemList'][0]] == "PHP For Dummies"

If you're using your database correctly, all you should need is the
number, anyhow...

---John Holmes...

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

Reply via email to