Merge branch 'master' into uat
[readifood.git] / lib / forms.php
index ae08607..5751f78 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) {
     echo "  <option value=\"$value\"";
     if (! isset($selected)) $selected = $_POST[$select];
+    if (! isset($selected)) $selected = get_last_selected($select);
     if ($value == $selected) echo " selected";
     echo ">$text\n";
   }