2

I have a list that I created which is now being changed into a document library.

I created the library. I have scripts on the list to help me with some functions: A field only shows when "Other" is selected in a dropdown, and 2 other fields only show on the view or edit screens.

Is there a way to make these functions happen in the document library? My 2 scripts are:

<script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
<script>    
$(document).ready(function(){

//Show/hide columns based on Choice Field Selection
$("select[title='Other Filings']").change(function() {
  if ($("select[title='Other Filings']").val() != "Other")
  {
    $('nobr:contains("Other Description")').closest('tr').hide();
  }
  else
  {
    $('nobr:contains("Other Description")').closest('tr').show();
  }
});
});

</script>

and

<script>    
$(document).ready(function(){
$('nobr:contains("Docketed")').closest('tr').hide();
  //Show/hide columns based on Choice Field Selection
  if ($("select[title='Docketed']").val() != "Yes")
  {
    $('nobr:contains("Docketed")').closest('tr').hide();
  }
  else
  {
    $('nobr:contains("Docketed")').closest('tr').show();
  }
});
});

</script>
  • Yes. You can apply scripts to library edit for. Did you try adding these scripts to your library edit form? If yes, what is the issue you are having? – Venkat Konjeti Jun 5 '17 at 19:04
  • I added them using the script editor. Nothing seems to be happening. Where in the edit form should I add them? Do I create a new edit form? Also, I feel like they should be in the new form because they should occur when a new document is filed but the only forms I find is upload, edit, and display. – Kimberly Abaid Jun 5 '17 at 19:10
  • I understand you have to execute this logic when update document properties. If this is the case you click edit properties and in that page, you need to add script editor web part and add your logic. – Venkat Konjeti Jun 5 '17 at 19:15
  • 1
    For a document library, you will have only "EditForm.aspx" which can be used update file metadata for a new one or old one. – Venkat Konjeti Jun 5 '17 at 19:30
-1

Note:

change your scripts to:

$("select[title='Other Filings']").change(function() {
      var TR=$('nobr:contains("Other Description")').closest('tr');
      if ($("select[title='Other Filings']").val() === "Other") TR.show();
        else TR.hide();
    });
});

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.