Lambert 的个人资料Lambert Qin's technical ...照片日志列表更多 工具 帮助

日志


8月31日

Create an survey with pictures and other HTML formats

One of the limitations of SharePoint is that it only support an simple text format survey which is not enough for many scenarios.

However, create a full customized ASP.NET survey for SharePoint is not easy, it involves a lot of coding work.

Here is an general method that help administrartors and power users who have limited coding skill to build a beautiful survey.

Step 1: create an OOB survey.

image

Step 2: Open the survey in SharePoint Designer,upload a picture which would be used later.

image

Step 3:Create a HTML page in SharePoint Designer, design your survey. Copy the HTML code.

image

Step 4:Paste the HTML into the question (notice: must include the Table tag)

image

Preview:

image

Step 5:Copy the JavaScript to the form files (newForm,editForm and etc.)

document.getElementsByTagName('Table').item(0).outerHTML
=
document.getElementsByTagName('Table').item(0).outerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');

Tips: if you do not know where to insert the code, look for the following area which contains an OOB JavaScript code

image

Preview:

image

 

Comments:

The functionality of the JavaScript converts the escape character back, so that the pictures and HTML codes display correctly.

 

Updates [2009-11-02]:

Thanks for Mike Sharp’s idea here: http://social.technet.microsoft.com/Forums/en-US/sharepointcustomization/thread/8b97bc31-f72d-4104-bd40-d8d72a8f7fbf

There should be a potential for XSS, and narrow the scope of what gets un-escaped should reduce the risks:

For DispForm, NewForm and EditForm pages. using
document.getElementById('onetIDListForm').rows[0].cells[0].innerHTML = document.getElementById('onetIDListForm').rows[0].cells[0].innerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');
For the Summary page doesn't have the same onetIDListForm cell, using the ID of the web part zone TD cell:
document.getElementById('MSOZoneCell_WebPartWPQ2').innerHTML = document.getElementById('MSOZoneCell_WebPartWPQ2').innerHTML.replace(/&lt;/g,'<').replace(/&gt;/g,'>');