8

When selecting multiple values, the data is separated with semicolons. When many values are selected it starts looking cluttered.

Is there any way to have each value on a new line?

For example, instead of:

Image1;Image2;Image3

I would like:

Image1
Image2
Image3

I'm using a lookup column inside a picture library. When looking at it within SPD it renders as a webpartpages:ListFormWebPart.

Is there any way of accomplishing this with Javascript?

7

I had a similar item come across my dest a few days ago. Using javascript and jquery. The code replaces the html coding of a semicolon with a html line break. It then copies the code and replaces the orginal code with it.

$(document).ready(function(){
  $(".ms-vb:contains(';')").each(function(){
    var htmlstr = $(this).html();
    var htmlmod = htmlstr.replace(/; <A/g,"</br><A");
    $(this).html(htmlmod);
  });
});
  • Thanks so much, this code really helped. One remark: I did have to lower the capitalization of the A tags: var htmlmod = htmlstr.replace(/; <a/gi,"</br><a"); – Ferdy Oct 7 '13 at 10:29
1

I think Spservice and multiple choice filed values will help you to work around this problem.

0

You might be able to use an article by Dessie Lunsford to create a calculated column to search and replace the semi colon with a space. This one might be helpful too.

  • 1
    I appreciate your help, but I don't think a calculated column will help me in this instance. The calculated column will not let me select the lookup column I need to alter. The lookup column is a semicolon separated list of multiple images that belong to another picture library. I was able to use javascript to replace the semicolon with a line break, but it breaks the links of the images. Anyone have any ideas? – user2302 Feb 2 '11 at 13:55
0

I ran into the same problem as the OP and found @JBlountJr answer to work fine except on our users with IE11. This code was able to do the trick in all our browsers. Hopefully this helps someone.

Note: I modified the DispForm.aspx page and gave the the lookup column an Id. Edit: Previous code actually did a few funky things to the URL's.

 $("#myId").contents().filter(function() {
    if (this.nodeType === 3){
        $(this).before('<br>'); 
        $(this).remove();
    }
 });

or

$("#myId").contents().filter(function() {
    if (this.nodeType === 3){ 
        $(this).replaceWith('<br>');
    }
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy