[LON-CAPA-cvs] cvs: loncom /cgi imagechoice.pl

www lon-capa-cvs@mail.lon-capa.org
Sat, 19 Apr 2003 23:52:37 -0000


www		Sat Apr 19 19:52:37 2003 EDT

  Modified files:              
    /loncom/cgi	imagechoice.pl 
  Log:
  Toward bug #1274 - determines image height, width, image x and y position,
  to be put into
  formname: name of the form
  formx: name of the input field for x
  formy: same for y
  formwidth: field for width
  formheight: field for height
  
  
Index: loncom/cgi/imagechoice.pl
diff -u loncom/cgi/imagechoice.pl:1.1 loncom/cgi/imagechoice.pl:1.2
--- loncom/cgi/imagechoice.pl:1.1	Tue Feb 11 20:58:37 2003
+++ loncom/cgi/imagechoice.pl	Sat Apr 19 19:52:37 2003
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 #
-# $Id: imagechoice.pl,v 1.1 2003/02/12 01:58:37 www Exp $
+# $Id: imagechoice.pl,v 1.2 2003/04/19 23:52:37 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -44,13 +44,30 @@
 
 
 if ((defined($data{'x'})) && (defined($data{'y'}))) {
+    my $output='';
+    if ($data{'formwidth'}) {
+	$output.='parent.'.$data{'formname'}.'.'.$data{'formwidth'}.
+	    '.value=document.pickimg.width;';
+    }
+    if ($data{'formheight'}) {
+	$output.='parent.'.$data{'formname'}.'.'.$data{'formheight'}.
+	    '.value=document.pickimg.height;';
+    }
+    if ($data{'formx'}) {
+	$output.='parent.'.$data{'formname'}.'.'.$data{'formx'}.
+	    '.value='.$data{'x'}.';';
+    }
+    if ($data{'formy'}) {
+	$output.='parent.'.$data{'formname'}.'.'.$data{'formy'}.
+	    '.value='.$data{'y'}.';';
+    }
     print <<"ENDSUBM";
 Content-type: text/html
 
 <html>
 <script>
     function submitthis() {
-	alert('Submitting '+document.pickimg.height+' '+document.pickimg.width);
+	$output
     }
 </script>
 <body bgcolor="#FFFFFF" onLoad="submitthis()">