Does anyone knows how to accomplish the task stated in the title? I know we can create fancy surveys with Sharepoint, but my goal is somewhat different: I want to display one question on my main page and allow users to submit their responds and see results there.

Note: I have only jQuery at my belt but I believe I can communicate with Sharepoint web services with it.



First off, there's really no benefit to using a Survey list for this particular application. You can simply set up a Custom List with the columns you'd like to capture. There's some funkiness to Surveys that you simply don't need (branching, etc.)

Secondly, make it easier on yourself and use my SPServices jQuery library (http://spservices.codeplex.com) to write the responses to the list (UpdateListItems) and read the full set of responses back (GetListItems).

  • Thanks, I will definetely look into SPServices. I used SPServices in another project (SP2007) and loved it. – frbry May 22 '11 at 1:33
  • By the way, I think I should keep the Survey list because end-users could use it to create their surveys and responses. – frbry May 22 '11 at 1:40
  • Using the survey list probably won't hurt you, but a custom list with one item per question would probably be just as easy to manage. Columns would be something like: Question, Responses (1-n), Start and End Date (assuming you'll cycle questions), etc. – Marc D Anderson May 22 '11 at 4:54

I believe you can access Survey information through the List web service (from what I understand a Survey is a SharePoint list). Below is a chunk of jQuery that I often steal from when calling SharePoint web services from jQuery:

<script type="text/javascript>
 $(document).ready(function() {
 var xmlData ="<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/
2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001
/XMLSchema'><soap:Body><GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'><listName>Shared Documents</listName><query><Query 
  xmlns=''><OrderBy><FieldRef Name='Title' /></OrderBy></Query></query><viewFields><
ViewFields xmlns=''  /></viewFields><queryOptions><QueryOptions xmlns='' /></queryOptions></GetListItems></soap:Body></soap:Envelope>";

   url: "/_vti_bin/lists.asmx",
   type: "POST",
   dataType: "xml",
   data: xmlData, 
   error: ErrorFunc,
   contentType: "text/xml; charset=\"utf-8\""


function SuccessFunc(result) {
//xml node with namespace need to be handled differently for jQuery
 $(result.responseXML).find("z\\:row").each(function() {

function ErrorFunc(result) {


Stolen from here.

It probably won't be exactly what you need, but it should be a good starting off point.


If you're going to be using client-side script, I would recommend using the Javascript Client Object Model as it will handle making the web service call, creating the post XML, parsing the results, etc.

var surveyItems = null;
function getSurveyItems() {
    var ctx = new SP.ClientContext.get_current();
    var surveyList = ctx.get_web().get_lists().getByTitle('MySurvey');
    var caml = new SP.CamlQuery();
    surveyItems = surveyList.getItems(caml);

    ctx.executeQueryAsync(Function.createDelegate(this, itemsRetrieved), 
                       Function.createDelegate(this, itemsNotRetrieved));

function itemsRetrieved() {
    var enumerator = surveyItems.getEnumerator();
    while (enumerator.moveNext()) {
        var surveyItem = enumerator.get_current();

        // internal name for one of the questions
        // this will output the answers

function itemsNotRetrieved() {
    alert('Could not retrieve list');

You have to make sure the following controls are loaded some where on the page:

<SharePoint:ScriptLink ID="ScriptLink1" runat="server" Name="sp.js" Localizable="false" LoadAfterUI="true" />
<SharePoint:FormDigest ID="FormDigest1" runat="server" />

The first one links the Javascript library for the COM. The second one insert a security token in a hidden input on the page, which lets the site know you are authenticated. Otherwise, it may not let you retrieve data. These controls are usually already on the page but if something is not working, try adding these.


Another option you might consider is using the XSLT List View Web Part. Just drop it on a page and its out-of-the-box XSL templates show the results and link you to the survey taking form. There are a couple of OOB views to choose from, you will probably want the "Graphical Summary". These can be selected in the web part properties. Also, you can customize the results data presentation by editing the XSLT with Designer.

  • I'd prefer taking the Data View Web Part path. I find it easier to modify. – frbry May 22 '11 at 1:34

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.