Page 1 of 1

select multiple tag problem

Posted: Fri Apr 07, 2006 7:10 am
by jito
i am having a problem with the following multiple select tag. my code is as follows:

Code: Select all

test.php


<?php

foreach($sel as $val)
print "$val<br>";

?>
<FORM METHOD=POST ACTION=test.php>
<select multiple name=sel>
<option value=1>one</option>
<option value=2>two</option>
<option value=3>three</option>
<option value=4>Four</option>
</select>
<input type=submit value=submit>
</form>
when this page is executed i am getting an error as invalid argument supplied to foreach
if i give multiple select as
<select multiple name=sel[]>
my code is executing and showing the selected values.
but i want to execute my code with
<select multiple name=sel>
is there any way out

Posted: Fri Apr 07, 2006 7:53 am
by feyd
is there an actual reason behind wanting to not use sel[]?

viewtopic.php?t=45711 may be of interest.

Posted: Fri Apr 07, 2006 8:04 am
by jito
hi,
i have seen it working somewhere but i'm not able to use it. i just want to know is it possible to do so.

Posted: Fri Apr 07, 2006 8:04 am
by feyd
if you read the thread I linked to, you'll get your answer.