I have 50 fields on a checkbox whcih i have to display on web. I want to display same in 4 columns please suggest how to do the same on web
Subject: Check box columner display on web
Hi,
You write “I have 50 fields on a checkbox”
You have 1 checkbox field with 50 choices or 50 fields (checkbox type) with n choices?
Be more precise, please.
Thierry
Subject: RE: Check box columner display on web
Sorry, I meant 50 choices on a single CheckBox field. Which i need to display in 4 columns on web.
Please suggest a way
Subject: Check box columner display on web
Hi,
I wrote this formula a while ago. Put in into a computed value and it will generate the HTML for the checkboxes, organized into columns. Set the variable “options” to the options you want (in a list) and change the variable targetFieldName to the name of the field in which you’d like to store the options. You als need to add a field with that name (hidden) to your document.
options := "option " + (“a”:“b”:“c”:“d”:“e”:“f”:“g”:“h”:“i”:“j”:“k”:“l”:“m”:“n”:“o”:“p”);
targetFieldName := “StoreHere”;
@If(options=“”; @Return(“”); “”);
selected := @GetField(targetFieldName);
@If(!@IsDocBeingEdited; @Return(@Implode(selected; “
”)); “”);
selected_html := “<input type="checkbox" name="”+targetFieldName+“" [id] value="” + selected + “">”;
selected_html_checked := “<input type="checkbox" name="”+targetFieldName+“" [id] value="” + selected + “" checked>”;
options_html := “<input type="checkbox" name="” + targetFieldName + “" [id] value="” + options + “">”;
options_html_all := @Replace(options_html; selected_html; selected_html_checked);
els := @Elements(options);
o := “”;;
@For(n := 1; n <= els; n := n + 1;
o := o : ( @ReplaceSubstring(options_html_all[n]; "[id]"; "id=\""+targetFieldName+@Text(n)+"\"") + "<label for=\"" + targetFieldName + @Text(n) + "\">" + options[n] + "</label>")
);
o := @Trim(o);
cols := @If(
els <= 4; 1;
els <= 8; 2;
3);
mod := @Modulo(els; cols);
col_entries := @Integer( els / cols);
col1 := col_entries+@If(mod=2; 1; mod);
col2 := col_entries+@If(mod=2; 1; 0);
col3 := col_entries;
REM {add hidden field with same name: needed to be able to clear all checkboxes};
fldEmpty := “<input type="hidden" name="” + targetFieldName + “" value="" />”;
divStart := “<div style="padding: 0px; margin-right: 40px; display: inline; float: left;">”;
divStart + @Implode( @Subset(o; col1) ; “
”) + “” +
@If(cols>=2; divStart + @Implode( @Subset(@Subset(o; col1+col2); -col2) ; “
”) + “”; “”) +
@If(cols>=3; divStart + @Implode( @Subset(o; -col3) ; “
”) + “”; “”) +
fldEmpty + “<br style="clear: both" />”
Subject: RE: Check box columner display on web
Hi Mark,
Moreover i had one more problem with the code u provided. As i tried to save and access the targetFieldName. But when i viewed through document properties of the document, if i save using this code my targetFieldName was still blank. Am i missing something or can u suggest the reason for the same
Subject: RE: Check box columner display on web
Hi Shweta,
What you need on your form is:
-
A computed value with the formula from my first post, marked as passthru HTML.
-
A computed field (hidden for web/ notes) with a formula of @Trim(@ThisValue).
-
The name of the field in 2. must be entered in the formula, variable “targetFieldName”. Note that it must be defined as a string, i.e. if the name of your field is StoreHere, the variable must be defined as:
targetFieldName := “StoreHere”;
That’s it. If you submit the form, the field in 2 should contain the selected options.
Also, if you don’t want to save the document, but need it on your web page only, you need to use JavaScript.
Subject: RE: Check box columner display on web
Thanks, Mark! To others, remember to make your hidden field allow multiple values. Thanks again, Mark. You made my day.
Subject: RE: Check box columner display on web
I have Alias set the values in the checkbox and i do not need to save the form just using the values in the checkbox and doing some operation.Thus when i use this code alias also get visible to user. Is there a option to use same wihout saving the form