locked
SharePoint 2007 - List customization RRS feed

  • Question

  • Hello,

    I need to know how to customize a list so that when a user populates a field, the list will either hide or reveal columns based upon the previous selection.  For example, if the column is a yes/no radio button and the user selects "Yes", then next column would appear and allow them to populate another field.  If they select "No" the field would remain hidden and they would move on.

    Thanks,

    Sydney

    Friday, June 21, 2013 6:12 PM

Answers

  •  I do something similar, Here is what I do when they select disapproved to show a disapproved comment box.

    //Remember this is Jquery

    // title is equal to the field name Approval so in SharePoint my column to evaluate is called Approval and it is a drop down thus the select. If it were a text field you would use input.

    if ($("select[title='Approval']").val() != "Disapproved"){

    // nobr is on the html and disapproved comments is the title of the column.

    // is it perfect if you have two columns named the same, no but in a pinch this can work.

    $('nobr:contains("DisapprovedComments")').closest('tr').hide();

    {

    else

    {

    $('nobr:contains("DisapprovedComments")').closest('tr').show();

    }

    //that does not handle the onchange event, see below for that.

    $("select[title="Approval"]").change(function() {

    if ($("select[title='Approval']").val() = "Disapproved"){

    $('nobr:contains("DisapprovedComments")').closest('tr').show();

    }

    });

    // then you can do an else for this also...

    You would have to wrap this in a $(document).ready(function(){

    again Jquery but if you want to do it this way it works.. Also you could place this code in a file or in a web content editor... As long as you have the jquery library in a folder. Then you could place a link to that folder via a masterpage link...

    });

    Thus you could do a hide when edit.aspx is open and when the approval is equal to disapproved it will show the disapproved comment box.


    R/ Art M


    Friday, June 21, 2013 8:11 PM

All replies

  •  If you would like to do client side JavaScript. 

    You could use JQuery to do this for you with some easy JavaScript.

    If you need more information let me know.

     


    R/ Art M

    Friday, June 21, 2013 7:55 PM
  •  I do something similar, Here is what I do when they select disapproved to show a disapproved comment box.

    //Remember this is Jquery

    // title is equal to the field name Approval so in SharePoint my column to evaluate is called Approval and it is a drop down thus the select. If it were a text field you would use input.

    if ($("select[title='Approval']").val() != "Disapproved"){

    // nobr is on the html and disapproved comments is the title of the column.

    // is it perfect if you have two columns named the same, no but in a pinch this can work.

    $('nobr:contains("DisapprovedComments")').closest('tr').hide();

    {

    else

    {

    $('nobr:contains("DisapprovedComments")').closest('tr').show();

    }

    //that does not handle the onchange event, see below for that.

    $("select[title="Approval"]").change(function() {

    if ($("select[title='Approval']").val() = "Disapproved"){

    $('nobr:contains("DisapprovedComments")').closest('tr').show();

    }

    });

    // then you can do an else for this also...

    You would have to wrap this in a $(document).ready(function(){

    again Jquery but if you want to do it this way it works.. Also you could place this code in a file or in a web content editor... As long as you have the jquery library in a folder. Then you could place a link to that folder via a masterpage link...

    });

    Thus you could do a hide when edit.aspx is open and when the approval is equal to disapproved it will show the disapproved comment box.


    R/ Art M


    Friday, June 21, 2013 8:11 PM