Forum Moderators: coopster & phranque

Message Too Old, No Replies

cgi-lib.pl

         

expat123

1:51 am on Aug 28, 2003 (gmt 0)

10+ Year Member




How do I use cgi-lib.pl to capture the value and text of a select list?

<select name=mylist>
<option value=1>Red
<option value=2>Blue
</select>

$input{'mylist'} returns 1 or 2 but I would like to capture 'Red' or 'Blue' as well. How can I do this?

thanks

jatar_k

3:21 am on Aug 28, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld expat123,

I do not believe you can. The only values that are posted are the variable name and the value. In this particular case the varname is mylist and the value woud only ever be 1 or 2.

You have a couple of options. You could change the value to red and blue instead of the number or you could maybe use a combined value that uncluded both the number and the string.

I would think though that you always know that 1=red and 2=blue so it could easily be hard coded into the form processor.

Is there some reason you need both?