--- loncom/interface/lonhtmlcommon.pm 2005/11/15 21:08:47 1.119 +++ loncom/interface/lonhtmlcommon.pm 2006/02/22 19:22:49 1.121 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.119 2005/11/15 21:08:47 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.121 2006/02/22 19:22:49 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -207,6 +207,28 @@ sub checkbox { return $Str; } + +=pod + +=item radiobutton + +=cut + +############################################## +############################################## +sub radio { + my ($name,$checked,$value) = @_; + my $Str = '&"'); - $values[$i] =~ s/([\r\n\f]+)/\\n/g; - $values[$i] =~ s/"/\\"/g; - } - if ($$elements{$name} eq 'text') { - my $numvalues = @values; - if ($numvalues > 1) { - my $valuestring = join('","',@values); - $output .= qq| + @{$values{$name}} = &Apache::loncommon::get_env_multiple($key); + } + } + } + + foreach my $name (keys(%values)) { + for (my $i=0; $i<@{$values{$name}}; $i++) { + $values{$name}[$i] = &HTML::Entities::decode($values{$name}[$i],'<>&"'); + $values{$name}[$i] =~ s/([\r\n\f]+)/\\n/g; + $values{$name}[$i] =~ s/"/\\"/g; + } + if ($$elements{$name} eq 'text') { + my $numvalues = @{$values{$name}}; + if ($numvalues > 1) { + my $valuestring = join('","',@{$values{$name}}); + $output .= qq| var textvalues = new Array ("$valuestring"); var total = courseForm.$name.length; if (total > $numvalues) { @@ -1620,67 +1668,65 @@ sub set_form_elements { courseForm.$name\[i].value = textvalues[i]; } |; - } else { - $output .= qq| - courseForm.$name.value = "$values[0]"; + } else { + $output .= qq| + courseForm.$name.value = "$values{$name}[0]"; |; - } - } else { - $output .= qq| + } + } else { + $output .= qq| var elementLength = courseForm.$name.length; if (elementLength==undefined) { |; - foreach my $value (@values) { - if ($$elements{$name} eq 'selectbox') { - $output .= qq| + foreach my $value (@{$values{$name}}) { + if ($$elements{$name} eq 'selectbox') { + $output .= qq| if (courseForm.$name.options[0].value == "$value") { courseForm.$name.options[0].selected = true; }|; - } elsif (($$elements{$name} eq 'radio') || - ($$elements{$name} eq 'checkbox')) { - $output .= qq| + } elsif (($$elements{$name} eq 'radio') || + ($$elements{$name} eq 'checkbox')) { + $output .= qq| if (courseForm.$name.value == "$value") { courseForm.$name.checked = true; }|; - } - } - $output .= qq| + } + } + $output .= qq| } else { for (var i=0; i