Solved

How to open SharePoint form in modal popup?

Posted on 2013-02-04
3
2,348 Views
Last Modified: 2013-05-08
I have a custom list with 3 content types. I would like to create a page with 3 buttons linked to NewForm for each content type. I would like the forms to open in modal dialogs. What is the easiest way to accomplish this for a non-programmer? I have seen some instructions online how to do modal dialogs with JavaScript but I need some help to walk me through how it should be done in my scenario.
0
Comment
Question by:MisUszatek
  • 2
3 Comments
 
LVL 44

Expert Comment

by:Rainer Jeschor
ID: 38852812
Hi,

probably the following should work:
<script type="text/javascript">
function OpenPopup(contenttypeid) {
	var url = "../lists/YourCustomList/NewForm.aspx?ContentTypeId=";
    var options = {
        url: url + contenttypeid,
        title: 'Add a new item',
        allowMaximize: false,
        showClose: true,
        width: 600,
        height: 500,
        dialogReturnValueCallback: refreshCallback
    }
    SP.UI.ModalDialog.showModalDialog(options);
}
</script>
<input type="button" text="New Content Type x" onclick="javascript:OpenPopup('0xYOURCONTENTTYPEIDofX');" />
<input type="button" text="New Content Type y" onclick="javascript:OpenPopup('0xYOURCONTENTTYPEIDofY>');" />

Open in new window



Just adjust the path to your list and the content type ids.

HTH
Rainer
0
 

Author Comment

by:MisUszatek
ID: 38853324
Can you please provide some more instructions how/where to add the script/code to a SharePoint page?
0
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 400 total points
ID: 39061466
Hi,
sorry I missed your last comment.
Either you add the lines directly on the page using SharePoint designer OR you store the text inside of a text file (should be extension .txt), upload the file to a SharePoint document library and then add a Content Editor Web Part to that page and configure the web part to use the above uploaded text file as source.

I mostly prefer solution 2, because I do not always have access to SharePoint designer. Therefore I create a central Content Asset library (its just a document library) and I upload all texts, scripts ... to that library.

HTH
Rainer
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
Summary In SharePoint 2010 it is easy to create custom color themes to jazz up a site. Theme colors can also be created in PowerPoint 2010 with a few clicks. But how do the chosen colors actually look in the SharePoint site? The attached PowerPoint…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question