[ic] Using checkboxes to write multiple values to one field

Ed LaFrance interchange-users@interchange.redhat.com
Mon Feb 18 12:09:00 2002


At 01:40 PM 02/18/2002 +1030, you wrote:
>I am trying to use checkboxes on my form as follow:
>
><INPUT TYPE="CHECKBOX" NAME="somename" VALUE="A" [checked name=somename
>multiple=1 value="A"]> A<BR>
>
><INPUT TYPE="CHECKBOX" NAME="somename" VALUE="A"  [checked name=somename
>multiple=1 value="B"]> B<BR>
>
><INPUT TYPE="CHECKBOX" NAME="somename" VALUE="C" [checked name=somename
>multiple=1 value="C"]> C<BR>
>
>It seems that that everything works fine, but when have a look at my
>table through admin interface I can see only A while B and C are not
>there.
>
>I know that they are there since I tried to retreive them with following
>script:
>
>
>  <B>Checkbox results are: </B>[perl arg="cgi"]
>         $somename= $Safe{cgi}->{somename};
>         $somename=~ s/\0+/|/g;
>         return $somename;
>     [/perl]
>
>
>My question is: How can I make those to be all visible in admin
>interface?
>
>Any help appricaited.

The problem is probably the null-separation of the strings.  You may want 
to filter the input after it is collected and before it is written to 
disk.  The [table-editor] works in conjunction with the mv_metadata table 
to do this automatically (when you set the widget type and filter in the 
mv_metadata table).

If you want to use your own form instead of the [table-editor], you can do 
something like this:

<form action...> #the start of your form
<input type=hidden name=mv_click value=remove_nulls>
...  #the body of the form
</form>

[set remove_nulls]
         $CGI->{somename} =~ s/\0+/ /g;
         return;
[/set]

- Ed L.

===============================================================
New Media E.M.S.               Software Solutions for Business
463 Main St., Suite D          eCommerce | Consulting | Hosting
Placerville, CA  95667         edl@newmediaems.com
(530) 622-9421                 http://www.newmediaems.com
(866) 519-4680 Toll-Free       (530) 622-9426 Fax
===============================================================