X-Git-Url: http://git.plutz.net/?p=shcgi;a=blobdiff_plain;f=forms.sh;fp=forms.sh;h=69c76302d4c2be06995d66fb77628d1b00e878c4;hp=50cb20431a15061370b879f8664d3d567a46fa6d;hb=8d60af41a80ea3760dd51c3bc34eab68d88b16ae;hpb=c287482dc24988cabd48a085e6d752d12b489550
diff --git a/forms.sh b/forms.sh
index 50cb204..69c7630 100755
--- a/forms.sh
+++ b/forms.sh
@@ -22,6 +22,7 @@
setopt -o OCTAL_ZEROES 2>&-
form_radio(){
+ # Produce a single radio button and an associated label
# Usage: form_radio Name Value Condition Label
# if "Condition" is the same as "Value", the button will be checked
@@ -38,6 +39,7 @@ form_radio(){
}
form_check(){
+ # Produce a checkbox and an associated label
# Usage: form_check Name Value Condition Label
# if "Condition" is the same as "Value", the Checkbox will be checked
@@ -52,3 +54,20 @@ form_check(){
printf '' \
"$id" "$name" "$value" "$check" "$id" "$label"
}
+
+form_radio_list(){
+ # Produce a group of radio buttons
+ # Buttons can be given in the form label/value either as parameters,
+ # or as lines on stdin
+ # if hte button value matches cond, this button will be selected
+
+ name="$1"
+ cond="$2"
+ shift 2
+
+ if [ -n "$*" ]; then for each in "$@"; do
+ form_radio "$name" "${each##*/}" "$cond" "${each%/*}"
+ done; else while read each; do
+ form_radio "$name" "${each##*/}" "$cond" "${each%/*}"
+ done; fi
+}