0

How do i add javascript to the form library new form, since i published infopath form as default form page.

I am using sharepoint 2013 and infopath 2013 to customize the form. Is there any way to add script/ jquery to theform.

IS Sharepoint designer is the only option?

1

You can add a javascript file using the content web part.

You can do this by

Edit page -> Add web part -> Media and content -> Content editor -> Add

Edit the source of the web part and add the following code into it:

​<script src="/sites/subsite/list/SiteAssets/file.js" type="text/javascript"></script><script src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>

Add the js file under Site Assets using SharePoint Designer.

0

yes you can, check the link out below:

http://blogs.msdn.com/b/infopath/archive/2010/03/18/introduction-to-programming-in-infopath-2010.aspx

its too big to go through to post here! bottom line is you need to add codebehind and add

private string BindScript(string ScriptUrl, bool PickFromSiteCollection)
{
    if (PickFromSiteCollection)
        ScriptUrl = Microsoft.SharePoint.Utilities.SPUrlUtility.CombineUrl(SPContext.Current.Site.RootWeb.Url, ScriptUrl);
    else
        ScriptUrl = Microsoft.SharePoint.Utilities.SPUrlUtility.CombineUrl(SPContext.Current.Web.Url, ScriptUrl);
    return string.Format(@"<script type=""text/javascript"" src=""{0}""></script>", ScriptUrl);
}

call the above method in an event that you require (override) like onload or onsubmit ect

writer.Write(BindScript("/_layouts/1033/js/jquery.min.js", true));
5
  • sorry ali...i couldnot use the code in the infopath since client is not allowed to do so....is there any solution apart from this – Arul Aug 20 '13 at 5:21
  • when you say not allowed to do so how do you mean exactly? asin hasnt get the right privligaes to run code? – Ali Jafer Aug 21 '13 at 10:39
  • Ali...i have to do jquery in submit action....if so...i need to use edit code option...which will take me to custom code...which i am not suppose to do as per client requirement.... – Arul Aug 21 '13 at 15:03
  • tell me if so any solution....or let me know if i m not right – Arul Aug 21 '13 at 15:04
  • add content editor and edit in html.put your javascript there. – SharePointMan Mar 13 '14 at 4:37

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.