« Return to the blog entry
Here's the formula I use. Edit the first three fields.
REM {Change FieldName to the name of the field you want to use in a check box};
FieldName := "County";
list := @DBColumn(""; ""; "Counties"; 1);
cols:=3;
w:=@Text(@Integer(90/cols));
e:=@Elements(list);
f:=@Round(e/cols);
g:=@If(f*cols<e; f+1; f);
colLines:=@If(cols>1;g;e);
temp := @If(cols>1;"<div class=\"column\" style=\"width: "+w+"%\">";"");
@For(n := 1; n <= e; n := n + 1;
temp := temp + @If(n>=g & @Modulo(n;g) = 1;"</div><div class=\"column\" style=\"width: "+w+"%\">"; "") + "<input type=\"" + inputType + "\" name=\"" + FieldName + "\" id=\"" + FieldName + @Text(n) + "\" value=\"" + list[n] + "\"" + @If(@IsMember(list[n];@GetField(FieldName)); " checked"; "") + "><label for=\"" + FieldName + @Text(n) + "\" class=\"" + inputType + "\">" + list[n] + "</label>"+@NewLine);
temp+ @If(cols>1;"</div>";"")
And here's the CSS that goes along with it.
<style type="text/css">
div.column { float: left; padding-right: 0.75em; }
table.columns { border-collapse: collapse; border-width: 0; }
table.columns td { padding: 0 1em 0 0; }
</style>
Here's the formula I use. Edit the first three fields.
REM {Change FieldName to the name of the field you want to use in a check box};
FieldName := "County";
list := @DBColumn(""; ""; "Counties"; 1);
cols:=3;
w:=@Text(@Integer(90/cols));
e:=@Elements(list);
f:=@Round(e/cols);
g:=@If(f*cols<e; f+1; f);
colLines:=@If(cols>1;g;e);
temp := @If(cols>1;"<div class=\"column\" style=\"width: "+w+"%\">";"");
@For(n := 1; n <= e; n := n + 1;
temp := temp + @If(n>=g & @Modulo(n;g) = 1;"</div><div class=\"column\" style=\"width: "+w+"%\">"; "") + "<input type=\"" + inputType + "\" name=\"" + FieldName + "\" id=\"" + FieldName + @Text(n) + "\" value=\"" + list[n] + "\"" + @If(@IsMember(list[n];@GetField(FieldName)); " checked"; "") + "><label for=\"" + FieldName + @Text(n) + "\" class=\"" + inputType + "\">" + list[n] + "</label>"+@NewLine);
temp+ @If(cols>1;"</div>";"")
And here's the CSS that goes along with it.
<style type="text/css">
div.column { float: left; padding-right: 0.75em; }
table.columns { border-collapse: collapse; border-width: 0; }
table.columns td { padding: 0 1em 0 0; }
</style>