2

I just started using this tool, so I tested SetValue in order to familiarize myself with it. It seemed to only work whenever I hit the "Ok" button to the Content Editor web part of the new/edit form. Whenever I actually tried to create/edit a form, I was met with blank fields. Could someone let me know what I could be missing?

Here's my code:

<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="/MySite/SiteAssets/Code/SPUtility/sputility.min.js"></script>
<script>
    // wait for the window to load
    $(document).ready(function () {
       // EXAMPLE: Set the value of the Title field to Hello world!
       SPUtility.GetSPField('Title').SetValue('Hello world!');
       SPUtility.GetSPField('Occurrence No.').SetValue('25');
    });
</script>
  • I once ran into a problem where my script was not executing because I forgot the "type" attribute in the script tag. Try changing your opening script tag to <script type="text/javascript"> – Dylan Cristy Mar 3 '16 at 18:19
  • @DylanCristy You are the man! That worked! Thanks! You should post that as an answer and I will mark it. – blutuu Mar 3 '16 at 19:23
  • I will add it as a real answer then. – Dylan Cristy Mar 3 '16 at 19:24
4

I once ran into a problem where my script was not executing because I forgot the "type" attribute in the script tag. Try changing your opening script tag to

<script type="text/javascript">
| improve this answer | |

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.