Make textareas dynamically resizable.
[readifood.git] / lib / forms.php
index ae08607..c71c11f 100644 (file)
   }
 
   function textarea($name, $value = null) {
-    echo "<textarea name=\"$name\">";
+    $id = "textarea_$name";
+    echo "<textarea id=\"$id\" name=\"$name\" cols=30>";
     if (isset($value)) echo $value;
     else echo $_POST[$name];
     echo "</textarea>";
+    echo "<script>\n  $(function() {\n";
+    echo "    $(\"#$id\").autosize();\n";
+    echo "  });</script>";
   }
 
   function option($select, $value, $text, $selected = null) {