Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to open SharePoint form in modal popup?

Posted on 2013-02-04
3
Medium Priority
?
2,634 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 1600 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

886 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