summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeff <jeff>2007-02-08 01:39:01 +0000
committerjeff <jeff>2007-02-08 01:39:01 +0000
commitc596647a05d29ca82878b47dbc78112916c19950 (patch)
tree1dd4b1932b11ddc69a2292cd48d311fcc70c5f4b
parent8a716df39598d30d12c51ebb5ce2bdc17933722c (diff)
add support from select-multiple
-rw-r--r--Changes7
-rw-r--r--META.yml2
-rw-r--r--SelectLayers.pm40
3 files changed, 37 insertions, 12 deletions
diff --git a/Changes b/Changes
index 677c656..9387d09 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,12 @@
Revision history for Perl extension HTML::Widgets::SelectLayers.
+0.07 Wed Feb 07 05:33:00 PST 2007
+ - Also overdue: add support for select-multiple
+ "form_elements" instead of the old form_* options.
+ - eliminate dubious fchanged javascript function
+ - check the type against undefined rather than the object itself
+ in copyelement
+
0.06 Wed Dec 20 01:50:00 PST 2006
- Also long overdue: add auto-sensing of form field types, pass
"form_elements" instead of the old form_* options.
diff --git a/META.yml b/META.yml
index 3bc1223..34ac425 100644
--- a/META.yml
+++ b/META.yml
@@ -1,7 +1,7 @@
# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: HTML-Widgets-SelectLayers
-version: 0.06
+version: 0.07
version_from: SelectLayers.pm
installdirs: site
requires:
diff --git a/SelectLayers.pm b/SelectLayers.pm
index 63887c6..5444071 100644
--- a/SelectLayers.pm
+++ b/SelectLayers.pm
@@ -3,7 +3,7 @@ package HTML::Widgets::SelectLayers;
use strict;
use vars qw($VERSION);
-$VERSION = '0.06';
+$VERSION = '0.07';
=head1 NAME
@@ -93,9 +93,8 @@ form_action - Form action
form_elements - (optional) Array reference of form fields to copy from the
B<form_name> form. Field type is autodetected; currently
- text, hidden, checkbox, and select (single) fiels are
- supported. Select (multiple) and radio fields are not yet
- supported.
+ text, hidden, checkbox, and select fields are
+ supported. Radio fields are not yet supported.
form_text - (optional) Array reference of text (or hidden) form fields to copy
from the B<form_name> form.
@@ -106,8 +105,8 @@ form_checkbox - (optional) Array reference of checkbox form fields to copy from
form_radio - (optional) Array reference of radio form fields to copy from the
B<form_name> form.
-form_select - (optional) Array reference of select (not select multiple) form
- fields to copy from the B<form_name> form.
+form_select - (optional) Array reference of select form fields to copy from
+ the B<form_name> form.
fixup_callback - (optional) subroutine reference, returns supplimentary
JavaScript for the function described above under FORMS.
@@ -184,7 +183,7 @@ END
#form fields
$html .= <<END;
- <FORM NAME="${key}$layer" ACTION="$form_action" METHOD=POST onSubmit="${key}fixup(this)" STYLE="margin-top: 0; margin-bottom: 0">
+ <FORM NAME="${key}$layer" ACTION="$form_action" METHOD=POST onsubmit="${key}fixup(this)" STYLE="margin-top: 0; margin-bottom: 0">
END
foreach my $f ( @$form_elements, @$form_text, @$form_checkbox, @$form_radio, @$form_select )
{
@@ -239,11 +238,30 @@ sub _fixup {
<SCRIPT>
function copyelement(from, to) {
- if ( from == undefined ) {
+ if ( from.type == undefined ) {
to.value = '';
} else if ( from.type == 'select-one' ) {
to.value = from.options[from.selectedIndex].value;
//alert(from + " (" + from.type + "): " + to.name + " => (" + from.selectedIndex + ") " + to.value);
+ } else if ( from.type == 'select-multiple' ) {
+ var i = 0;
+ var count = 0;
+ var values = new Array();
+ for (i=0;i<from.length;i++) {
+ if (from.options[i].selected){
+ values[count++] = from.options[i].value;
+ }
+ }
+ for (i=0;i<values.length-1;i++) {
+ var clone = to.cloneNode(true);
+ clone.value = values[i];
+ to.form.appendChild(clone);
+ }
+ if (count > 0) {
+ to.value = values[values.length-1];
+ }else{
+ to.value = '';
+ }
} else if ( from.type == 'checkbox' ) {
if ( from.checked ) {
to.value = from.value;
@@ -263,9 +281,9 @@ function copyelement(from, to) {
END
$html .= "
- function ${key}fchanged(what) {
- ${key}fixup(what.form);
- }
+ //function ${key}fchanged(what) {
+ // ${key}fixup(what.form);
+ //}
function ${key}fixup(what) {\n";
foreach my $f ( @$form_elements ) {