in reply to Multiple item selects and CGI.pm headaches!

The onsubmit option is the way to go:

-- test.tmpl --
<html> <head> <title>Test Page</title> <script language="javascript"> <!-- function move_opt(source, destination) { for(var i = source.length - 1; i >= 0; i--) { if (source.options[i].selected) { destination.options[destination.length] = new Option(sourc +e.options[i].text, source.options[i].value); source.options[i] = null; } } } // --> </script> <body> <form action="test.cgi" method="get" onsubmit="for(var i = 0; i < docu +ment.forms[0].box2.length; i++){document.forms[0].box2.options[i].sel +ected = 'selected'}"> <table> <tr> <td> <select name="box1" size="5" multiple="multiple"> <!-- TMPL_LOOP NAME="list" --> <option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_V +AR NAME="text" --></option> <!-- /TMPL_LOOP --> </select> </td> <td> <input type="button" value="->" onclick="move_opt(document.for +ms[0].box1, document.forms[0].box2);"><br /><br /> <input type="button" value="<-" onclick="move_opt(document.for +ms[0].box2, document.forms[0].box1);"> </td> <td> <select name="box2" size="5" multiple="multiple"> </select> </td> </tr> <tr> <td colspan="3" align="center"><input type="submit" value="sub +mit"></td> </tr> </table> </form> </body> </html>
-- show_test.cgi --
#!/usr/bin/perl -w use CGI; use HTML::Template; use strict; my @ref = ( { value => '1', text => 'a', }, { value => '2', text => 'b', }, { value => '3', text => 'c', }, { value => '4', text => 'd', }, { value => '5',text => 'e', }, ); my $q = new CGI; print $q->header; my $template = HTML::Template->new(filename => 'test.tmpl'); $template->param(list => \@ref); print $template->output;
-- test.cgi --
#!/usr/bin/perl -w use CGI; use strict; my $q = new CGI; print $q->header; print "$_<br>" foreach $q->param('box2');
I used method="GET" just to show the selected info in the URL.

--
Rock is dead. Long live paper and scissors!