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

rss

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 Kozlov
    Dmitry Kozlov
    Admin
    Member for: 9 years 8 months 7 days
    #1 by Dmitry Kozlov Feb 10 ’14 at 04:29

    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]
    
  • MES5464
    Member
    Member for: 9 years 9 months 2 days
    #2 by MES5464 Feb 10 ’14 at 10:37

    Thank you so much!

  • GregFitz
    Member
    Member for: 8 years 22 days
    #3 by GregFitz May 6 ’15 at 11:20

    [#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

     

  • rostislav
    rostislav
    Moderator
    Member for: 8 years 22 days
    #4 by rostislav May 7 ’15 at 03:58

    [#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.

  • GregFitz
    Member
    Member for: 8 years 22 days
    #5 by GregFitz May 11 ’15 at 01:29

    [#4]:

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

     

    All the best,
    Greg

     

     

     

  • rostislav
    rostislav
    Moderator
    Member for: 8 years 22 days
    #6 by rostislav May 12 ’15 at 05:29

    [#5]: [#5]: [#5]:

    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.

  • GregFitz
    Member
    Member for: 8 years 22 days
    #7 by GregFitz May 12 ’15 at 06:27

    Perfect thank you, makes total sense  well done.

     

    Again thanks,
    Greg

     

Displaying 1 to 7 of 7 messages