Hi!
Yesterday i was adding a new script file into a NewForm.aspx file.
I had a problem with this because when i added the <script> tag with the file reference src=”” it doesn’t works.
I found that i have to put that in a content but i want to do it adding the tag in the NewForm.aspx. Can i do it?
I don’t want do it writting the JavaScript code into NewForm.aspx, want to add the Scrpt REFERENCE.
Can you tell me about this?
Hi Santiago,Is this in SP2013 or 2010? If 2013, you can add it to the JS Link configuration of the newform by performing the following:
- Create a .js file with your script in it
- Save to your site assets library perhaps in a special folder for .js files
- Using SharePoint Designer select the list you wish to make the change on and view the newform.aspx in the browser.
- Click on Edit Page
- Edit the form web part
- Under Miscellaneous add your file to the jslink: ~site/SiteAssets/JSFiles/foo.js (note if you need to include multiple files you can do it this way: ~site/SiteAssets/JSFiles/foo1.js|~site/SiteAssets/JSFiles/foo2.js
If you are working in SP2010 you can follow the example here. Read the comments though as your situation might require a bit different way depending on your needs and the comments on that page do discuss different ways to do it depending on your environment.