How to get "Choice Multiple" values in a display form?

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
MES5464
Posts: 94
Joined: Mon Aug 26, 2013

07 Feb 2014

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://spform.com/forms-designer- ... eld-values


However, I can't find seem to get the value of the field when it is a Display Form.

User avatar
Dmitry Kozlov
Site Admin
Posts: 1524
Joined: Thu Jun 07, 2012

10 Feb 2014

Hello,

Please, use the following code to get text representation of multiple choice field on a display form:

Code: Select all

fd.field('Choices').control()._el().text();
if it contains multiple values, you can split it by semicolon:

Code: Select all

fd.field('Choices').control()._el().text().split(';')[0]

MES5464
Posts: 94
Joined: Mon Aug 26, 2013

10 Feb 2014

Thank you so much!

GregFitz
Posts: 7
Joined: Thu May 14, 2015

06 May 2015

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

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

07 May 2015

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.

GregFitz
Posts: 7
Joined: Thu May 14, 2015

11 May 2015

Excellent thank you! Quick quesiton how would I alter silightly to do multiple fields on same form ?


All the best,
Greg

User avatar
rostislav
Moderator
Posts: 364
Joined: Mon Oct 19, 2015

12 May 2015

You can use this function:

Code: Select all

$.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.

GregFitz
Posts: 7
Joined: Thu May 14, 2015

12 May 2015

Perfect thank you, makes total sense well done.


Again thanks,
Greg

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 18 guests