How to get "Choice Multiple" values in a display form?
Posted by MES5464 - Feb 7 ’14 at 11:50
I have a multiple choice (checkbox) field and I have been able to get and set the values in code using the insturctions listed on
http://formsdesigner.blogspot.com/2013/04/getting-and-setting-sharepoint-form.html
However, I can't find seem to get the value of the field when it is a Display Form.
-
Dmitry KozlovAdminMember for: 9 years 8 months 7 days
Hello,
Please, use the following code to get text representation of multiple choice field on a display form:
fd.field('Choices').control()._el().text();
if it contains multiple values, you can split it by semicolon:
fd.field('Choices').control()._el().text().split(';')[0]
-
MES5464MemberMember for: 9 years 9 months 2 days
Thank you so much!
-
GregFitzMemberMember for: 8 years 22 days
[#1]: Hello, how do I ge the Multiple choice selections to display veritcally (per value) in the display form?
thanks assitance much appreicated as alwys!
Best,
Greg -
rostislavModeratorMember for: 8 years 22 days
[#3]: Hello,
Use the following code:
var fieldName = 'multipleChoice';
var html = fd.field(fieldName).control()._el().html();
html = html.replace(/;/g, '<br>');
fd.field(fieldName).control()._el().html(html);
Regards,
Rostislav.
-
GregFitzMemberMember for: 8 years 22 days
[#4]:
Excellent thank you! Quick quesiton how would I alter silightly to do multiple fields on same form ?
All the best,
Greg -
rostislavModeratorMember for: 8 years 22 days
You can use this function:
$.each($('.custom-formatting'), function() { var html = $(this).children('.fd_control').html() html = html.replace(/;/g, '<br>'); $(this).children('.fd_control').html(html); })
where 'custom-formatting' is the css class of the multiple choice field that you set in the Forms Designer (click on the multiple choice field -> on the right you see a table with different attributes for the field -> under LAYOUT find Css Class row -> add a class name, e.g. 'custom-formatting' in this case).
Regards,
Rostislav.
-
GregFitzMemberMember for: 8 years 22 days
Perfect thank you, makes total sense well done.
Again thanks,
Greg