Forum Moderators: coopster & phranque

Message Too Old, No Replies

Form submission

Problems with form handling

         

kidd

3:27 pm on Sep 25, 2002 (gmt 0)

10+ Year Member



Hello:

Im having a bit of a problem and I hope someone could help me out with this.

I have a form in my site which is kind of a survey, and yesterday I decided to enter a new field: "Favorite Bands".

I didnt want to use radio or check boxes so I decided to go with a multiple select box.

So I created the field which is something like this:


<select multiple size="5" name="bands" style="width:150">
<option value="Bon Jovi"> Bon Jovi </option>
<option value="Aerosmith"> Aerosmith </option>
<option value="Metallica"> Metallica </option>
<option value="Pink Floyd"> Pink Floyd </option>
<option value="Toto"> Toto </option>
</select>

I've never used this kind of input before but I thought it would be the same as any field, so I've added the field both in the form and in my CGI:


print FILE "Bands:" . $Input{'bands'};

When i tested the code I saw that the CGI was only writing the first band of the selection and not all of the selected bands, and I cant figure out what Im doing wrong

Can someone help me ot with this....

THANKS

jatar_k

4:18 pm on Sep 25, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I'm not really sure what you are doing. Are you just outputting after they submit? If so, it only passes the selected value not the whole list on submit.

circuitjump

4:18 pm on Sep 25, 2002 (gmt 0)

10+ Year Member



Hi kidd,
This is what I tested and well it works fine.


<form action="" method="post">
<select multiple size="5" name="bands" style="width:150">
<option value="Bon Jovi"> Bon Jovi </option>
<option value="Aerosmith"> Aerosmith </option>
<option value="Metallica"> Metallica </option>
<option value="Pink Floyd"> Pink Floyd </option>
<option value="Toto"> Toto </option>
</select>
<input type="submit">
</form>

<?php
print $bands;
?>

It works. Whats the code your using? PHP code I mean.