Re: [Phphtmllib-devel] multiple select box
Status: Beta
Brought to you by:
hemna
From: Walt B. <wab...@3g...> - 2003-03-12 17:54:44
|
Hi winston,=20 can you send me a the code that hows the error that you have? I haven't seen this problem with doing multiple selects before. Also I noticed the 4th param to the form_select() call, you are passing a string "true", which is incorrect. it should be a boolean, which is TRUE or FALSE Walt On Wed, 2003-03-12 at 06:50, winston ralph wrote: > Hi, > I have a problem with the multiple select box. I think it's a bug, but > maybe I'm doing something wrong. >=20 > I have a select box like: > <SELECT name=3D"products[]" multiple=3D"true" size=3D"15"> > <OPTION value=3D"22" SELECTED> > product1 > </OPTION> > <OPTION value=3D"02" SELECTED> > product2 > </OPTION> > <OPTION value=3D"05" SELECTED> > product3 > </OPTION> > <OPTION value=3D"04" SELECTED> > product4 > </OPTION> > <OPTION value=3D"10" SELECTED> > product5 > </OPTION> > </SELECT> >=20 > And using phphtmllib, I call it as so: > $select =3D form_select("products[]", $ProductList, $engineProductList, > "true"); >=20 > When it draws the select box all its values are the last value > in the $engineProductList array. >=20 >=20 > Heres what I think the select function should be. NOTE: $value is used > twice and gets overwritten so i've used $value2 >=20 > function form_select($name, $options=3Darray(), $selected=3D"") { >=20 > $select =3D new SELECTtag( array("name" =3D> $name) ); >=20 > while( list($label, $value) =3D each($options) ) { > $selected_value =3D ""; > if(is_array($selected)){ >=20 > # Note the use of $value2 so it doesn't overwrite $value above > foreach($selected as $key =3D> $value2){ > if ($label =3D=3D $key) { > $selected_value =3D "SELECTED"; > } > } > reset($selected); > } else { > if ($label =3D=3D $selected) { > $selected_value =3D "SELECTED"; > } > } > $attributes =3D array( "value" =3D> $value, $selected_value ); > $option =3D new OPTIONtag( $attributes ); > $option->push( $label ); > $select->push( $option ); > } > return $select; > } >=20 > Hope I've made myself clear. Any questions, pop me a line. >=20 > Regards, > Winston >=20 > -- > Winston Ralph -- Systems Developer >=20 >=20 > N=18=C2=ACHY=C3=9E=C2=B5=C3=A9=C2=9A=C2=8AX=C2=AC=C2=B2=C2=9A'=C2=B2=C2= =8A=C3=9Eu=C2=BC=C2=82=C2=AF*m (Z=C2=96W=C2=A7=C2=81=C3=A8=C2=AC=C2=9E=C2= =8C(=C2=A5=C3=A9=C3=86z=C3=97+i=C3=89"=C2=9E=06=C2=A7v=C2=B7 =C2=8A=C3=8B= ^=C2=AE=17=C2=ABy=C3=BA+=C2=B2=C2=89=C2=9E=C2=9A)=C3=9Dn=C2=88 =C2=96)=C3= =A0~=C3=A9=C3=9A=C2=9D=C3=9Bay=C3=88Z=C2=9D=C3=87=C2=A8=7F=08=C2=A7=C2=9E= )=C3=A0jp)=C2=A6W=C2=A2>=C2=87a=C2=B6=C3=9A=7F=C3=BD=C2=A7l=C2=B2=C2=8B=C2= =ABq=C3=A7=C3=A8=C2=AE=07=C2=A7z=C3=9F=C3=9C=C2=82&=C3=A2=C2=9F=C3=BA=C3=9E= v*=C3=9Er=C3=9Ae=C2=B6=16=C2=B0=C3=93M=C3=B5zs=C3=A1=C2=A6=1Bf=C2=96X=C2=9B= u=C3=AB=C3=9E=C2=96f=C2=A2=C2=96)=C3=A0=C2=96+->=1Aa=C2=B6ie=C2=89=C2=B7^= =C2=BD=C3=A9e=C2=8A=C3=8Bl=C2=B2=C2=8B=C2=ABq=C3=A7=C3=A8=C2=AE=07=C2=A7z= =C3=98m=C2=B6=C2=9B?=C3=BEX=C2=AC=C2=B6=C3=8B(=C2=BA=C2=B7=1E~=C2=8A=C3=A0= zw=C2=AD=C3=BEX=C2=AC=C2=B6=C3=8F=C3=A5=C2=8A=C3=8Bb=C2=9D=C3=BA?=C2=A6=1A= a=C2=B6ie=C2=89=C2=B7^ |