commit:c7a9e553a94c1eea9897db844f050616e88f3c42
author:Chip Black
committer:Chip Black
date:Thu Aug 10 01:03:53 2017 -0500
parents:45168d49904063881bf125e8fa1b653bd0af1aa3
Add HTML helper for select options
diff --git a/cgi-bin/html.lib b/cgi-bin/html.lib
line changes: +16/-0
index e97caab..e09976a
--- a/cgi-bin/html.lib
+++ b/cgi-bin/html.lib
@@ -32,6 +32,22 @@ sub img {
     "<img src=$src" . attr_expando(@_) . ">";
 }
 
+sub select_option {
+    $name = shift;
+    $value = shift;
+    $s = "<select name=$name>";
+    for $i (@_) {
+        if ($i eq $value) {
+            $s .= "<option selected>";
+        } else {
+            $s .= "<option>";
+        }
+        $s .= "$i</option>";
+    }
+    $s .= "</select>";
+    return $s;
+}
+
 sub friendnet {
     "<font color=red>Friend</font><font color=blue>Net!</font>";
 }