Poll for SharePoint

March 15, 2015: I have updated this solution. You find v2.0 here.

Please note: The Google Image Charts used in this solution is deprecated and will stop working April 20, 2015.

Change log
January 28. 2014
v1.54 fixes one incompatibility with SP 2013. I have not fully tested this so please let me know if you find any bugs.

July 01. 2013 v1.53: The sort order of answers in chart now reflects the order given in the setup. I have removed some script references so that you now must refer spjs-utility.js – get it here

You must update the CEWP code to include reference to spjs-utility.js

15.12.2011 v1.5.1: Bugfix in the file “PollForSharePoint.js” – line 238. The property “listBaseUrl” were missing – thanks to Jaap Dijkma for finding this bug.


04.12.2011 I have updated the solution to support putting the list in a central location. See “listBaseUrl” below.


22.10.2011 Updated the code to support free input rather than predefined answers – as requested by Claudia:

Hi, thank you for this wonderful piece of code, I think it’s great and we use it on our intranet :).
I wondered if it is possible to use a single line of text for free input instead of radiobuttons with preset answers?
We like to use the poll for ‘brandtagging’ so that people can type keywords.
Just wondering…..
thanks! Claudia

I thought this was a clever idea and have implemented this in v1.4. See updated CEWP code and description below.


17.08.2011 Updated the code with these changes:

  • Lets you view the results and come back to answer.
  • Tidied up the code.
  • The charts now supports https (Thanks to Google).
  • Removed the poll question from the chart title to preserve the formatting.

01.03.2011 Updated the code to fix a bug when “singleResponse” is true. Thanks to “Al”. I have also included two more settings in the “argObj”: qStyle and aStyle. These sets the CSS style of question and answers. See CEWP code below.


28.11.2010 Updated the code to support special characters in the poll question and answers. Thanks to Christophe for the tip.


This code lets you generate polls using JavaScript/jQuery only. No need for server side installed WebParts.

Poll
IMG

Result with column chart
IMG

Result with bar chart
IMG

Result with pie chart
IMG

Result with “table chart”
IMG

Already answered
IMG

Not active
IMG

Finished
IMG

The charts are generated using Google Chart Tools / Image Charts (aka Chart API).


Create a custom list with the following fields

  • Answer: Single line of text
  • Question: Single line of text

Name it anything you like, but keep the display name fairly simple (no special characters) as you will use the display name in the CEWP code.

CEWP code

The CEWP code below refers jQuery from Google. If you have a local copy of jQuery you can change the script src. You find the code for the file “PollForSharePoint.js” at the bottom of the page. In this example the file “PollForSharePoint.js” is placed in a document library named “Javascript”.

NOTE: You must change the script src for the file “PollForSharePoint.js” and “spjs-utility.js” to point your instance of the files – the CEWP code will not work unless you do this.

Place this code where you want the poll to appear:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/test/English/Javascript/Poll/spjs-utility.js"></script>
<script type="text/javascript" src="/test/English/Javascript/Poll/PollForSharePoint.js"></script>
<script type="text/javascript">

buildQueryWP({pollAnswerListName:'PollA',
				listBaseUrl:L_Menu_BaseUrl,				
				id:'myPoll_01-03-2011', // Allowed characters id a-z, 0-9 - and _
				start:'10/22/2011', // format: mm/dd/yyyy
				end:'11/10/2011', // format: mm/dd/yyyy
				singleResponse:false,
				q:"What is your<br />favorite junk food?",
				qStyle:'font-size:small;font-weight:bold;color:gray',
				aStyle:'font-size:xx-small',
				a:['Pizza','Hot dog','Hamburger','Neither of them'], // Leave empty for free input				
				color:['32CD32','FFCC11','FF3300','C0C0C0'],
				forceLowerCaseAnswer:false, // Group result by lowercase				
				chart:'col', // table, bar, col or pie
				height:100,
				width:450});
</script>

You can control these values in the top of the file “PollForSharePoint.js”:

var submitLinkText = 'Submit';
var backLinkText = 'Back';
var showResultBtnText = 'Show result';
var pollNotActiveText = 'The poll is not active prior to {0}';
var pollEndedText = 'The poll ended on {0}';
var alreadyRespondedText = 'You answered: ';
var totalResponsesLabel = "Total responses: ";

Object attributes explained

  • pollAnswerListName: DisplayName or GUID of the list that stores the answers
  • listBaseUrl: The baseUrl of the site. This is like “/sites/hr” when the list is located in the site “hr” under “/sites”. Use L_Menu_BaseUrl (or omit the property) for current site. New in v1.5
  • id: The unique id of the poll. All poll answers are stored in a list and this id is used to separate each poll
  • start: Start date in the format mm/dd/yyyy
  • end: End date in the format mm/dd/yyyy
  • singleResponse: true for one reply per user, false for unlimited number of replies
  • q: Poll question. To have a linefeed in the question, use <br>
  • qStyle: CSS syntax style
  • aStyle: CSS syntax style
  • a: Answers in an array format. To use free input and not predefined answers, leave the array empty.
  • color: Colors for the chart in an array format. This must have the same length as the previous parameter – one color for each answer
  • forceLowerCaseAnswer: Primarily for use with free input to avoid getting two “series” when the only difference are uppercase characters. New in v1.4
  • chart: “bar” for bar chart, “col” for column chart, “pie” for pie chart or “table” for a plain table.
  • height: Height in pixels
  • width: Width in pixels

Regarding free input
If you leave the attribute “a” as an empty array, the user can supply free text as “answer”. When using free input, the result are automatically presented as a table.

Download code

The code for the file “PollForSharePoint.js”:
Download code from this location

Ask if anything is unclear.

Alexander

225 thoughts on “Poll for SharePoint”

  1. Very interesting!

    I haven’t looked at the code yet, but I assume you’re using Web Services. You could “escape” the text to make it work with special characters.

    1. Hi Christophe,
      The problem with the special characters is not with the web service call, but when construction the URL query string that is passed to Google to retrieve the chart.

      Alexander

    1. Hi,
      I didn’t think this would do any difference, but you were right. I have updated the script to v1.1 – wrapping the question and answers in encodeURIComponent().

      Thanks!

      Alexander

  2. Thank you Alexander!

    Your solution works great as expected.
    Once again, I bow before your Awesomeness!
    Now you can be called Alexander the Great. 🙂

    1. Hi,
      This solution is using Google’s Chart Tools / Image Charts (aka Chart API)

      The only thing it “uses” Google for is to provide the image based on the <IMG src=”The URL to Google with all parameters in the query string”>

      Without Internet access you cannot use this solution with a “chart- result”. To use it in a non-Internet access scenario, look at the check for https in the code. In a case where the site is on a https protocol the result is supplied as numeric values.

      Alexander

  3. Is this Sharepoint 2010 Compatible?
    It is not working for me, I wonder if this is why,

    You help much appreciated,

    Anita

  4. Hello Alexander,
    Thank for your prompt reply!

    I created the custom list as indicated (Question, and Answer fields as single text… the system creates a “create by” and “modified by” fields as well, the default field title I changed for the Question field)

    I also copied the js file locally and invoke it appropiately…

    Now when I place the peace of code in the page as follows:

    buildQueryWP({pollAnswerListName:’EA4E27D2-D016-4270-B102-78F4105546A1′,
    id:’ea4e27d2-d016-4270-b102-78f4105546a1′, // Allowed characters id a-z, 0-9 – and _
    start:’11/22/2010′, // format: mm/dd/yyyy
    end:’12/25/2010′, // format: mm/dd/yyyy
    singleResponse:false,
    q:”What is your favorite junk food?”,
    a:[‘Pizza’,’Hot dog’,’Hamburger’,’Neither of them’],
    color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
    chart:’bar’, // bar, col or pie
    height:150,
    width:335});

    When I run it I get this error: An error ocurred, one of the fields has not been installed correctly. Go to the configuration page of the list and remove those fields (the error is actually is spanish)

    if I insert the custom list in the page it inserts the view webpart with this data:
    ListId=”ea4e27d2-d016-4270-b102-78f4105546a1″ ListName=”{EA4E27D2-D016-4270-B102-78F4105546A1}”
    ViewGuid=”{9DE8E267-4A8E-4577-92F4-1524942E6290}”
    ID=”g_9de8e267_4a8e_4577_92f4_1524942e6290″

    Any help, I would really appreciated!!!

    Thanks,

    Anita

    1. Hi, This message indicates that you have a mistake in the FieldInternalNames. The Title field is intended left as it is and you must add both the Answer and Question as new columns.

      Alexander

      1. Hi Alexander I get the same error : An error occurred, one of the fields has not been installed correctly. Go to the configuration page of the list and remove those fields. I didn’t change Title on my list instead I added two extra columns as per instruction “Question” and “Answer” and made those two fields single line text, then added the following on where I want the multiple choice question to show as follows:

        buildQueryWP({pollAnswerListName:’QPoll’, listBaseUrl:’http://sp2013/lgsite’, id:’Poll_26062014′, // Allowed characters id a-z, 0-9 – and _ start:’06/25/2014′, // format: mm/dd/yyyy end:’07/01/2014′, // format: mm/dd/yyyy singleResponse:false,
        q:”What is your favorite junk food?”, qStyle:’font-size:small;font-weight:bold;color:gray’, aStyle:’font-size:xx-small’, a:[‘Pizza’,’Hot dog’,’Hamburger’], // Leave empty for free input color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′], forceLowerCaseAnswer:false, // Group result by lowercase
        chart:’bar’, // table, bar, col or pie
        height:100,
        width:450});
        Please help me, what could I be doing wrong?
        Thanks in advance.

      2. Thanks Alexander, I went to check the fieldinternalname on the list again and apparently Sharepoint changed my fieldinternalname to “Questi” although I name it “Question”, there must have been another fieldinternalname using the same name. so I edited the PollForSharePoint.js file and changed “Question” to “Questi” and then it worked. Thanks a mill

        Lizo

    1. the submit button is working, even it is saving in the list. but the show result is not working.

  5. Is there a way to run this behind and HTTPS intranet site without the Security warnings. I dont have to be able to view the charts.

  6. Hi Alexander,

    Can this method be altered to display a graph of the results on a local intranet site without any eternal access to Internet, ie: Google?

    When I click on Submit, it displays a “can’t locate image” pic with a red X and a “Count: 3” underneath. (The count is the total number of responses to the Poll.)

    And because we’re behind a proxy, when the user clicks Submit, it brings up the “Enter you Internet Authentication Credentials” box.

    Ideas, Suggestions?

  7. I will try to find time to update this solution to use the Google Visualization API which can be used in a secure environment and does NOT send any data to Google: All code and data are processed and rendered in the browser. No data is sent to any server.

    The current solution uses Google Chart API which sends the data to Google for retrieving the chart as an image.

    Alexander

  8. Gee, I am feeling a bit left out. It works for everyone. . .except me. I have copied your source and made certain that my references to jquery and PollForSharePoint are correct. But when a choice selection is made and the Submit button is clicked an error occurs stating “An error ocurred – null”. Also, clicking the Show Result button does nothing.

    Any ideas? This is the first of your suggestions that I have failed to implement.

    1. Hi,
      I will set my money on wrong “pollAnswerListName”. It is (for your convenience) used the ListDisplayName in the example. If the list has some special characters in the DisplayName, try changing it – or even better – use the list GUID.

      Look her how to find the GUID

      Alexander

  9. Thanks Alexander, everything is working now. I am feeling a bit stupid. . . .but I’ll get over it, I always do!

  10. Alexander,
    Great web part!!!
    I found a problem with the “singleResponse” set to true. When you set “singleResponse” to true the selections for someone that has not responded do not show up.

    I fixed the code by adding the following line to function buildQueryWP(argObj), after the if (active), if(argObj.singleResponse) and ‘else’ statement but before the close { after the else:

    $(“#Poll_A_”+argObj.id).html(aBuffer.join(”));

    After I added this line the ‘singleResponse’ set to true work properly.

    Hope this helps.

    Al

    1. Good Morning,

      Thank you for this Web Part, we use it on our intranet since last year, I have the v1.2, and I didn’t have problem with the “SingleResponse” set true, but yesterday I wanted to change the question and when I set “singleResponse” to true the selections not show up. So, I downloaded the last version but I don’t find the problem.

      I hope your help

      thanks! Marly

  11. Alexander, thank you so much for this! I have been searching for a solution like this for ages! I can live with the https-restriction, but is there a way to decrease the font size of the question? Thanks!

    1. Hi,
      I did a test and could not get it to work with anonymous access. “Show results” could if we modify the code a bit, but not “answering”.

      I’m not quite sure why, but even with “full access” for anonymous users submitting answers fails with 403: Forbidden.

      I have no workaround at the moment.

      Alexander

  12. This is great, I’ve been scouring the internet for an easy to use solution. Here’s my question. Is there a way to change from allowing for a single answer per submission to multiple answers per submission? Possible to swap radio buttons to check boxes?

    Thanks endlessly for this!

    1. Hi,
      Single or multi is set in the configuration in the CEWP. This is to determine whether a user can answer multiple times – not multiple choices. There was a bug regarding “singleResponse”, but this is fixed in v1.2.

      Check boxes is not possible due to the many varieties of possible answer combinations – it has to be single choice.

      Alexander

  13. Dude, you rock,
    I was having the problem with the singleResponse:true not working, just came on to check and Bam, you’ve already updated the code. 😉
    My work Intranet has now got Single-Sign-On for Internet, so the Charts are displaying perfectly.
    One issue I had was for the Results Box, a long Question would cut-off in the web-part, so I had to disable line 284 in new JS file “&chtt=” so the question didn’t display. But other than that, this is a great web part!
    Great work,
    Brett

  14. Hi, is there any possibility that I could random my question using this? I had tired using different id and different end date, however when I run it, no questions seems to appear.

  15. Hi,

    This looks great! Is there a step by step procedure on how to implement this? It is unclear to me if I have to setup something in Sharepoint to make this work….

    Thanks,
    scott

  16. Hi Alexander,
    Your solution is great and I am currently using it in a client’s intranet and they love it.

    I do have a question:
    How can I just have a numbers as a result set. The client want a ‘thumbs up’ x amount of people like it (like facebook) instead of the graph.

    Thanks,
    Luis

  17. Alexander,

    I’m testing the SharePoint Poll for the first time.

    I have it working, however I have a question…

    After the results are displayed, short of refreshing the page, is there any way to get back to the poll?

    For example, if a visitor looks at the results first (without answering the poll), is it possible to place a back button on the poll so they can go back, re-read the question and possible answers, then place their vote?

    Thanks!

    1. Alex,

      One other question… The Poll works great in my SP2007 environment, but in my SP2010 environment I encountered a problem.

      Please see the link below.

      http://nivo.dev7studios.com/

      On my SP2010 site, I replaced my SP2007 sites static banner with a “Nivo Slider” web part. The slider is working fine and looks great.

      The problem is, as soon as I drop my “Poll for SharePoint” web part on the page, the slider stops loading/displaying images… And if I delete the Poll for SharePoint web part, the slider starts cycling thru images again.

      Can you image any reason why the Poll for SharePoint would interact with the Nivo Slider? Can you recommend a fix that would allow me to use both web parts on the same page?

      Thanks!

      1. Hi, I haven’t looked at it yet, but ensure you call jQuery only once.

        Alexander

  18. Alexander,

    I have another “Poll for Sharepoint” question…

    Would it be possible for you to modify the code so the poll pulled it’s questions and possible responses from a SP list?

    For example, given a SP list that contained a column for questions, and several additional columns for each of the possible responses, could the Poll for SP web part be modified so it displayed the 1st question and 4 possible responses, then when the visitor submitted their response, the poll would graphically display the results, along with a “Next” button. If the visitor clicked the “Next” button, that would cause the web part to display the next question in the list… Thereby allowing the visitor to cycle thru and respond to multiple poll questions?

    Thanks!
    DF

    1. Hi,
      Everything is possible, but with the limited time i have, i feel this one is as good as it gets 🙂

      Alexander

  19. Hey. Nice bit of code. I’ve been playing with it, and I notice two things about the poll question:

    1) The CSS styles get applied to the question if the user has not entered a response yet, but not to the question when the results are displayed.
    2) Using as a line break in the question works on the initial display, but again it does not work when the results are displayed (the question appears thus: “This isthe question” — no line break.

    Right now my solution is to modify the JS to remove the question entirely, and simply display that in the HTML above the answers. Any tips on how I might apply the same styling to the title on the results screen as is applied on the question screen?

  20. Hi,

    I keep getting an error message saying:

    “One or more field types are not installed properly. Go to the list settings page to delete these fields.”

    What am I doing wrong?

    Cheers,
    Jon

    1. Hi,
      You have a wrong/missing field name. In the list you must create two columns: “Answer” and “Question”

      These has to be new columns – you can not rename the title field.

      Alexander

  21. I tried using this technique under WSS 3.0. Under the single response mode how would the javascript code know what the current user id is. For me _spUserId is always null. If I set it to a valid user in the javascript code it works.

    1. Hi,
      The variable “_spUserId” is provided by SharePoint itself – trough the master page. Does your page inherit from the master page?

      Alexander

  22. Hi Alexander,

    This works great, but i’m getting a strange grey panel appearing at the top of my page and an error:

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; WOW64; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; OfficeLiveConnector.1.4; OfficeLivePatch.1.3; InfoPath.2; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E)
    Timestamp: Wed, 12 Oct 2011 13:18:14 UTC

    Message: ‘this.el.style.visibility’ is null or not an object
    Line: 109
    Char: 8
    Code: 0
    URI: http://intranet/WebResource.axd?d=_ok40Df4DyKI4FNoqkgVvLu94RIdKCcFQGEz6Q09yFrv-fIKWbnCk_CLe_bG7IUGInLq_A4apRMT8JeC-3GdvCXDUHknE5AgzgPO-iT7TEHpIasNutkn_DrH1UN92g4g4au3dGTN1avjrU2fbmsSPxqh5rDohZuHDLXaMuJzdHm2uZDp-dxCcz3d0M1EB7HQFTJii-1BiPewwlaow9lONYaHT0xTQE817uBLCM1eA9pB0xyU0&t=634177258816171641

  23. Hi, thank you for this wonderful piece of code, I think it’s great and we use it on our intranet :).
    I wondered if it is possible to use a single line of text for free input instead of radiobuttons with preset answers?
    We like to use the poll for ‘brandtagging’ so that people can type keywords.
    Just wondering…..
    thanks! Claudia

  24. I am getting this exception when anonymous user is trying to submit the volt?

    status:
    500

    responseText:
    soap:ServerServer was unable to process request. —> Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

    webserviceUrl:
    /_vti_bin/lists.asmx

    soapBody:
    PollA0<![CDATA[What is yourfavorite junk food?]]>

    1. Hi,
      This solution uses webservices and cannot be used without authentication.

      Alexander

  25. Hi, thanks for this really useful and easy to implement code. I’ve implemented it in the source code of a content editor web part, the poll appears (with the question and radio buttons) but when I click submit I get the error ” An error occurred! Null”
    Any thoughts? Thanks in advance
    AN

    1. Hi,
      Hard to tell, but if you send me some screenshots of your setup I can take a look.

      EDIT: Test v1.5 first.
      Alexander

  26. Hello Alexander, great code, thanks!

    I have a question: is it possible to use a poll-list on another (sub)site?
    In my situation, I would like to have the poll on the home page and the list (with several views) on the HR-subsite of my intranet.
    In your code I saw something like listBaseUrl, but I don’t see how I can use it.
    Regards,
    Aarnout

    1. little bugfix
      v1.5/PollForSharePoint.js line 238:
      res = spjs_QueryItems({listName:argObj.pollAnswerListName,query:query,viewFields:[‘ID’,’Answer’]});

      should be:

      res = spjs_QueryItems({listName:argObj.pollAnswerListName,listBaseUrl:argObj.listBaseUrl,query:query,viewFields:[‘ID’,’Answer’]});

  27. Greatly usefull tool! Thank you. Quick question – is it possible to enter more than 4 options. I’ve tried, but each time it breaks the poll. Any help would be greatly appreciated! Thanks

    1. I have used it with 16 options. Did you also put more than 4 colors in the color array?

    1. Follow the link at the bottom of the article. I have updated the link in case the redirect did not work.

      Alexander

  28. Hey Alexander, Great code you have here!

    I’ve just implemented it and can see results, looking good so far. Is there an option to always show the chart? So without having to click ‘Show Result’ first…

    Thanks in advance.

  29. Hi Alexander,
    The code works great but I’m wondering if I am doing something wrong b/c when I edit the test page housing the poll then save and close, I get duplicate polls in the CEWP and in the HTML there is a huge chunk of code present after the last

    I have both the PollforSharePoint.js file and the jQuery file stored in the same folder in SharePoint…is this the source of my issue? Thanks

    1. Hi,
      Use the content link option in the cewp “sidebar”, or use a HTML form web part.
      Alexander

  30. Hi Alexander,

    nice it works fine.
    If I have no internet connection, then the source code is not working to display the charts.So I copied the source code “http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js” in a *.js file that I uploaded to SharePoint.
    But the charts are not displayed…

    Can you tell me why this does not work?

    Thank you.

    1. Hi,
      The charts are created using Google Image charts – and this requires Internet access. There is no way you can display them without. Your only option is the use “table”.

      Alexander

  31. Alexander Thanks for the lovely polling webpart..I am getting this error on some portal visitors “An Error Occured…Access denied…You do not have permission to perform this action or access this resource” when user clicks on SUBMIT button…whats the problem?

    1. All users must have write access to the list where the answers are logged.

      Alexander

  32. Hey Alexander, thanks for the useful webpart. But can I add a column in PollForSharePoint.js? I really need it because my requirement is to make the poll answered only once by the user. I don’t want to use [Me] for calculated value on one column and set it to accept unique values because my site will have a lot of this poll.

    1. Hi,
      Set “singleResponse” to true in the argument object when calling “buildQueryWP”.

      Alexander

    2. Hey that was a fast response! And finally it’s working! Thanks Alexander, you’re the best. 😀

  33. I got this working, and it is a pretty useful tool. I’m wondering if it would be easy to change it to checkboxes instead of radio buttons so they could select more than one item? I know it isn’t as simple as changing the type to checkbox.

    1. Sorry for the late reply, but this is no easy fix as the solution will have to be rewritten to achieve this.

      Alexander

  34. Hi Alexander,

    I’m a bit confused how to set this up. I created a list with columns Title, Question and Answer and used a CEWP for adding the code. I can see the poll on the page but it is now pulling the questions from the list. Where do I link the list? Is it the base URL? I added the link to my list there but it is still not working. Any ideas?

    Thank You
    Tudor

    1. Hi,
      The questions is supplied in the script. The answers are logged in the list, alongside with the question, to be able to make a chart.

      Alexander

  35. –“Hi,
    The questions is supplied in the script. The answers are logged in the list, alongside with the question, to be able to make a chart.

    Alexander

    Ok, I still can’t seem to make it work :(. I have a list and used the listBaseURL ‘http://servername:port/company/Lists/’ and I used the GUID of the list for the pollAnswerListName and the id. Now for the ‘q’ field in the javascript I pasted the same question that I entered in the list.

    Now do I need to create 4 of the same question in the list if I want 4 answers, each one of the question has one answer? Or how can I make this work, how does it grab the answers?

    Thank You for any help!
    Tudor

    1. Hi,
      To find the correct base url, right click the page and select “view source”. Search for “L_Menu_BaseUrl”.

      Regarding the questions and answers: You are NOT supposed to enter these in the list. The list is for storing the answers as the users reply to the poll. The poll question and possible answers are set up in the “buildQueryWP” argument object.

      Alexander

  36. Thank you Alexander!!! That was my problem, I was not using the list for the storing the results, rather I thought they were being pulled from there. Thank very very very much for this, it works great!!! Thanks again,
    Tudor

  37. Hi Alexander,

    I could use your help. I’ve created a custom list as described above, saved the PollForSharePoint.js to a document library title Javascript, copied/pasted the code to the Rich Text Editor of a CEWP. I *think* I adjusted both the script src path and the listBaseUrl accordingly…but the code is still what is displayed on our main page, not the poll feature. I’m clearly missing a step. Any ideas?

    Thanks!
    Kristen

    1. You are not supposed to put the code in the rich text editor, but in source code editor. You could use the HTML form web part if you like. Alexander

    2. Hi Alexander,

      So I took what I had in Rich Text Editor and pasted it into Source Code Editor. What displays in my CEWP is this 01 02 03. Any more ideas?

      Thanks!

    3. Hi,
      Is there some code missing in your post?

      If you are copying the code from this page, ensure the line numbers are not copied (hover over the code and select view source)

      Alexander

    1. Hey A, long time. hope things are well with you. I thought this would work, but I must be missing something. I took the working code in 2010 and placed in 07, but it is blank. any suggestions?

    2. Never mind, not sure the issue, it may be related to the lower version of jquery. So running jquery 1.7 i was able to get ur script to work, all versions from 1.3 – 1.5.1.
      thanks again for all ur great work

  38. Hi – cool code. Getting “Total Responses: undefined”, which means none of the charts load. Any ideas?

    1. Probaly related to jQuery version. Ty using an older version of jQuery.

      Alexander

  39. Hi Alexander,
    Thanks for this cool post.
    i followed all your instruction but i am getting error “one or more field types are not installed properly”
    please see my code.

    buildQueryWP({pollAnswerListName:’B175C88B-F843-4F8D-BE16-5B75BF38FCBD’,
    listBaseUrl:’/English’,
    id:’1033′, // Allowed characters id a-z, 0-9 – and _
    start:’11/19/2012′, // format: mm/dd/yyyy
    end:’11/10/2013′, // format: mm/dd/yyyy
    singleResponse:false,
    q:”What is yourfavorite junk food?”,
    qStyle:’font-size:small;font-weight:bold;color:gray’,
    aStyle:’font-size:xx-small’,
    a:[‘Pizza’,’Hot dog’,’Hamburger’,’Neither of them’], // Leave empty for free input
    color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
    forceLowerCaseAnswer:false, // Group result by lowercase
    chart:’col’, // table, bar, col or pie
    height:100,
    width:450});

    can you please suggest me?

  40. the submit button is working, even it is saving in the list. but the show result is not working. the output is not coming in the page

  41. Great little script, however i am looking for a way to administer it, the polls will be changed regularly by our inhouse communications team, and obviously very few Marketing Majors would be capable of editing Javascript to set this up.

    Is there anything in the works that would allow for simple administration of the system?

  42. What a fantastic script! It works great for me as is, but I was wondering if there is any way to easily sort the results from highest to lowest, etc.

    Thanks for sharing your knowledge with all of us.

    1. You would have to edit the file “PollForSharePoint.js” to add this. Locate this line:

      query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>"+id+"</Value></Eq></Where>";

      and change it like this:

      query = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>"+id+"</Value></Eq></Where><OrderBy><FieldRef Name='NameOfColumnToSortBy' Ascending='false' /></OrderBy>";

      Alexander

  43. Thanks for sharing this. Is there a way to keep the results displayed all the time, so that the chart and legend appear even before the question is answered.

  44. Hi Alexandar,

    Firstly everthing you have here is brilliant. I’ve been able to save the responses to the list but the chart does not show up. I know that it needs to connect to google for the api. But anytime I used the external reference,answers stop showing up on the page. Only an internal jquery reference works. I tried using both references (which is not ideal) but still does not work. Any help will be apprecaited.

    Thanks,
    Srividya

    1. Hi,
      You do not need to refer jQuery from Google – I have done so just as an example. You will however need to have Internet access for the image to be returned from Google’s server after it has been processed.

      Alexander

  45. Hi Team,

    I am using this code but on click of Button ‘Submit’, i am not getting the result(graph).
    Is something wrong with the pollforsharepoint.js file? Is there any changes we need to make from our side?

    Please advise on the same.

    Thank you for your help in advance,
    Ritesh

    1. Hi,
      The graph is created by a call to Google’s server for processing an image. If you do not have Internet access, you will not get any graphs. Could this be the problem?

      There might be an issue with newer versions of jQuery – try using an older version for testing.

      Alexander

  46. Hi Alexander,

    Thanks for posting this!This is really a useful article. In fact every post of yours is amazing!But I have a question here. What if I do not want to show inactive polls? Not even the “question” of inactive polls.

    I removed the “else” part of “if(active)”

    else{
    $(“#Poll_A_”+argObj.id).html(notActiveMsg);
    }

    which indeed will not display the inactive message in the poll but the “question” still appears due to

    htmlBuffer.push(“”+argObj.q+””);

    Please help me in finding the solution

  47. Hiya! I simply would like to give a huge thumbs up for the great info
    you have here on this post. I will likely be coming again to your blog for extra soon.

  48. Alex, Thank you for the great solution. I looked high and low for a poll solution that didnt require creating a poll with Visual Studio and a new CWP or a third party solution. This will be great when I finally get it working. I do have one question, I followed your instructions: created a customs list, added 2 colums (Answer, Question), created a new poll.aspx page, added a CEWP and added the script. When I preview the page in the browser, the answers do not display on the page and there is an error that _spUserId is undefined in PollForSharePoint on line 237. Any thoughts or ideas on how I can fix this. I ran my poll.aspx page from both the allfiles directory and from within the list and get the same error. I think this error is causing my answers not to populate on the screen. I downloaded jquery and PollForSharePoint and imported them to SiteAssets. Im stumped. Thanks in advance for you assistance.

    Best,
    Dan

    1. Hi,
      Which SharePoint version are you using?

      If it’s 2010 or 2013, search and replace _spUserId with:

      _spPageContextInfo.userId

      Let me know if this works.

      Alexander

      1. I was not able to get it working and I’m working in a 2010 environment.

        Thank you,
        Dan

      2. Yes, I am still getting the same error. Here is the code Im running:

        Content Editor
        Allows authors to enter rich text content.
        /_layouts/images/mscontl.gif
        g_013d2cb0_2fd2_49ae_9e27_9883cd3df15f
        <![CDATA[

        buildQueryWP({pollAnswerListName:’testjquerypoll’,
        listBaseUrl: ‘/Lists’,
        id:’music-01′, // Allowed characters id a-z, 0-9 – and _
        start:’06/06/2013′, // format: mm/dd/yyyy
        end:’06/12/2013′, // format: mm/dd/yyyy
        singleResponse:true,
        q:”Select music channels you would like EMS to stream.”,
        qStyle:’font-size:small;font-weight:bold;color:black’,
        aStyle:’font-size:small’,
        a:[’50s’,’60s’,’70s’,’80s’], // Leave empty for free input
        color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
        forceLowerCaseAnswer:false, // Group result by lowercase
        chart:’col’, // table, bar, col or pie
        height:100,
        width:450});

        ]]>
        2

        I’ve also placed the CEWP outside of a webpart zone and that yeilds the same error. I even tried running the code on an aspx page without CEWP. Thank you again for the quick replies and the assistance.

        Dan

      3. Content Editor
        Allows authors to enter rich text content.
        /_layouts/images/mscontl.gif
        g_013d2cb0_2fd2_49ae_9e27_9883cd3df15f
        <![CDATA[

        buildQueryWP({pollAnswerListName:’testjquerypoll’,
        listBaseUrl: ‘/Lists’,
        id:’music-01′, // Allowed characters id a-z, 0-9 – and _
        start:’06/06/2013′, // format: mm/dd/yyyy
        end:’06/12/2013′, // format: mm/dd/yyyy
        singleResponse:true,
        q:”Select music channels you would like EMS to stream.”,
        qStyle:’font-size:small;font-weight:bold;color:black’,
        aStyle:’font-size:small’,
        a:[’50s’,’60s’,’70s’,’80s’], // Leave empty for free input
        color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
        forceLowerCaseAnswer:false, // Group result by lowercase
        chart:’col’, // table, bar, col or pie
        height:100,
        width:450});

        ]]>
        2

  49. hi,
    Is there way for putting more than one questions,
    in this web part?
    please suggest me for this.

  50. Thanks so much for the awesome code, looks like it’s exactly what I want.
    I’ve been trying to get it working for about 8 hours now and would love some help.
    The survey is adding the results to the list fine but the results are not returning. I don’t think this is even getting to the web call.
    The call in PollForSharePoint.js > ShowResults – spjs_QueryItems – is returning -1 answers.
    I’ve looked further into this function and the inputs look fine. I also believe internet access should not be a problem, but not completely ruling it out. Any suggestions would be appreciated.
    Great java/SP skills by the way!

    1. Hmmm put in older versions for PollForSharePoint 1.3 and the spsj script and the answers now display. ??

    2. Sorry for the late reply. I have tested setting this up in a new site to ensure it works as intended. In my test it does, and I suspect you may have an error in your setup: Could you have references to multiple versions of spjs-utility.js in the page?

      In my test: jQuery v1.10.2, spjs-utility.js v1.171, PollForSharePoint v1.5.3.

      Alexander

  51. Hello alexander,

    I have download Poll ForSharePoint.js file can you provide me the script document which is help me to understand the script function..Reply ASAP I am waiting for your responce

    Thanks
    Deepak chauhan

      1. Hello alexander

        Step:1–First of all i have create the custom list PollA (Columns::Question And Answer) and enter one manually entry in this list

        Step–And then create the page and add content query web part and past the below code

        buildQueryWP({pollAnswerListName:’PollA’,
        listBaseUrl:http://sp2010:44859/Lists/Polls/AllItems.aspx,
        id:’myPoll_01-03-2011′, // Allowed characters id a-z, 0-9 – and _
        start:’10/22/2011′, // format: mm/dd/yyyy
        end:’11/10/2011′, // format: mm/dd/yyyy
        singleResponse:false,
        q:”What is yourfavorite junk food?”,
        qStyle:’font-size:small;font-weight:bold;color:gray’,
        aStyle:’font-size:xx-small’,
        a:[‘Pizza’,’Hot dog’,’Hamburger’,’Neither of them’], // Leave empty for free input
        color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
        forceLowerCaseAnswer:false, // Group result by lowercase
        chart:’col’, // table, bar, col or pie
        height:100,
        width:450});

        there is no output after the above step so please tell me how can i use this functionality

        My Site URL::http://sp2010:44859/
        Custom List::PollA (Custom column-1:: Question and Column-2::Answer )
        Library Where save the js file::DocLibrary

        configure my ::Object attributes according to my above details

        Reply ASAP

    1. Please be patient!
      From the first look, the listBaseUrl is wrong. If the list is in the current site, use the variable in the example: L_Menu_BaseUrl

      Use the developer console to look for errors (hit F12 in Internet Explorer – select “Console”).

      Alexander

  52. These Error are showing when we press F12

    HTML1202: http://sp2010:44859/SitePages/pollA.aspx is running in Compatibility View because ‘Display intranet sites in Compatibility View’ is checked.
    pollA.aspx
    SEC7115: :visited and :link styles can only differ by color. Some styles were not applied to :visited.
    pollA.aspx
    SCRIPT438: Object doesn’t support property or method ‘addMethods’
    SPUtility.js, line 20 character 1

    how can i remove these errors

  53. Alexander Bautz,

    The poll answer are submit successfully and saved in list but when we click on show result so show result is not working …reply

    Thanks
    Deepak chauhan

  54. Alexander Bautz,

    I have internet access but the but the show result is not working.
    also i have add the

    Reply ..

    Thanks
    Deepak chauhan

    1. Hi,
      Considering that this is a free solution, I think that you demand to much of the support. You cannot be this impatient and demand answers. I have helped you on the way, but I cannot hold your hand all the way.

      I suggest you set up a clean test site / list and follow the article in detail.

      Good luck, and feel free to ask again, but then you must be a bit more patient and appreciative.

      Alexander

      1. hello

        I have create the fresh solution but the problem is still there so please help me how can i show the chart on click of show result button ..I have tried the

        ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js” and

        /DocLibrary/jquery-1.9.min.js

        thanks
        deepak chauhan

      2. hello

        I have create the fresh solution but the problem is still there so please help me how can i show the chart on click of show result button ..I have tried the

        ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js” and

        /DocLibrary/jquery-1.9.min.js

      3. You must provide screenshots of the CEWP code, and information on SharePoint version and browser version and I’ll see what I can do. Also, I must have any error messages from the developer console.

        Alexander

  55. Thank you Alexander!

    Your solution works great as expected.
    Once again, I bow before your Awesomeness!
    Now you can be called Alexander the Great. 🙂 Really great work

    Thanks for your support………

    According to me your rating is ***************************

      1. I am using this solution on office-365 and what is base url of list my site url is https://deepakinfotech.sharepoint.com/ so i use the this for listbaseurl attribute but the question is display and answer is not display

        ​​

        buildQueryWP({pollAnswerListName:’PollA’,
        listBaseUrl:’https://deepakinfotech.sharepoint.com/’,
        id:’myPoll_23-10-2013′, // Allowed characters id a-z, 0-9 – and _
        start:’10/22/2011′, // format: mm/dd/yyyy
        end:’11/10/2014′, // format: mm/dd/yyyy
        singleResponse:false,
        q:”What is your favorite junk food?”,
        qStyle:’font-size:small;font-weight:bold;color:gray’,
        aStyle:’font-size:xx-small’,
        a:[‘Pizza’,’Hot dog’,’Hamburger’,’Neither of them’], // Leave empty for free input
        color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
        forceLowerCaseAnswer:false, // Group result by lowercase
        chart:’pie’, // table, bar, col or pie
        height:100,
        width:450});

  56. Hii,

    I have two more queries

    1::Can i add more than four option in asnwer
    2::Can i set other style of answer radio button to any other control like check box or dropdown

    Thanks
    Deepak chauhan

  57. Hello sir,

    Is any possibility in PollForSharepoint.js the answer should be pick up through custom list
    reply asap

    Thanks
    Deepak chauhan

  58. Hi Alex,
    I am trying to use an array for parameter ‘a’ so that the number of options can be dynamic instead of hard coded values Instead of this ‘Pizza’,’Hot dog’,’Hamburger’,’Neither of them’ , i am trying to pass an array. But no luck all values appear as single option 🙁 .

    var options = new Array(“Yes”,”may be”,”No”);
    is it possible that i pass ‘options’ variable as value for parameter ‘a’

    Thanks
    Ankit G

    1. Hi Ankit,
      This is no problem. Define the array like this (manually, or using code):

      var myAnswers = ['Pizza','Hot dog','Hamburger','Neither of them'];

      And then use the variable “myAnswers” like this:

      buildQueryWP({pollAnswerListName:'Poll',
      		listBaseUrl:"",//L_Menu_BaseUrl,				
      		id:'Poll_1', // Allowed characters id a-z, 0-9 - and _
      		start:'08/22/2013', // format: mm/dd/yyyy
      		end:'08/28/2014', // format: mm/dd/yyyy
      		singleResponse:false,
      		q:"What is your<br />favorite junk food?",
      		qStyle:'font-size:small;font-weight:bold;color:gray',
      		aStyle:'font-size:xx-small',
      		a:myAnswers,				
      		color:['32CD32','FFCC11','FF3300','C0C0C0'],
      		forceLowerCaseAnswer:false, // Group result by lowercase				
      		chart:'col', // table, bar, col or pie
      		height:100,
      		width:450});

      Please note that the array “colors” must be the same length as the “a” array.

      Alexander

    2. Here is an example on how to query a list for the answers and the colors. You can adapt the code to suit your needs. Add a custom list with two single line of text fields: “Answer” and “HexColor”. Call this list something like “PollSetup”.

      Use this code in the CEWP:

      function getMyPollAnswers(listName,key){
      	var res, q, b;
      	q = "<Where><Eq><FieldRef Name='Title' /><Value Type='Text'>"+key+"</Value></Eq></Where>";
      	res = spjs_QueryItems({"listName":listName,"query":q,"viewFields":["Title","Answer","HexColor"]});
      	b = {"a":[],"c":[]};
      	$.each(res.items,function(i,item){
      		if(item.Answer !== null){
      			b.a.push(item.Answer);
      			b.c.push(item.HexColor);
      		}
      	});
      	return b;
      }
      
      var myAnswersAndColors = getMyPollAnswers("PollSetup","poll1");
      
      buildQueryWP({pollAnswerListName:'Poll',
      				listBaseUrl:"",//L_Menu_BaseUrl,				
      				id:'Poll_3', // Allowed characters id a-z, 0-9 - and _
      				start:'08/22/2013', // format: mm/dd/yyyy
      				end:'08/28/2014', // format: mm/dd/yyyy
      				singleResponse:false,
      				q:"What is your<br />favorite junk food?",
      				qStyle:'font-size:small;font-weight:bold;color:gray',
      				aStyle:'font-size:xx-small',
      				a:myAnswersAndColors.a, // Leave empty for free input				
      				color:myAnswersAndColors.c,
      				forceLowerCaseAnswer:false, // Group result by lowercase				
      				chart:'col', // table, bar, col or pie
      				height:100,
      				width:450});

      Note the variable “myAnswersAndColors” and the “a” and “color” in the argument to “buildQueryWP”.

      Alexander

    3. And one more thing: The Title field must contain the “key” spesified in the function call to “myAnswersAndColors”:

      var myAnswersAndColors = getMyPollAnswers("PollSetup","poll1");
      

      Alexander

  59. First… this is great! i’ve been looking everywhere for a poll wp.

    Question: i have added your js files, and code to a CEWP on my test site, and created the custom list with question and answer columns. When i click submit i get “an error occurred! One or more field types are not installed properly. Go to the list settings page and delete these fields.”

    the only thing i can think is that the question column is the default “title” column that i renamed. is there anything else that could cause this error?

      1. thanks it is working now. but when i click show result it’s not rendering the chart… do you know what would cause this?

        i’m also getting that “internet explorer blocked this website from displaying content with security certificate errors.” SHOW CONTENT – button

      2. when i click “show result” the place where the chart would be shows a red ‘x’ with the alt text being “Result.” and on that same page i get the fore mentioned script error.

  60. Hi Alexander

    This is fantastic, just wondered if there is a way to hide the results from the people submitting?

    Sorry if this has already been asked but I couldn’t see it amongst all the questions.

    Thanks

  61. Hi Alexander,

    In the poll I am able to view only the question,submit button,results option…
    The answers(Radio buttons) are not displayed. neither the button works..
    Also i created the two columns question and answer.
    Below is the cewp code. I used the latest code and files mentioned in the blog.
    This is CEWP code i referred

    buildQueryWP({pollAnswerListName:’PollList’,
    listBaseUrl:L_Menu_BaseUrl,
    id:’myPoll3′, // Allowed characters id a-z, 0-9 – and _
    start:’10/22/2013′, // format: mm/dd/yyyy
    end:’11/10/2014′, // format: mm/dd/yyyy
    singleResponse:false,
    q:”What is your favorite junk food?”,
    qStyle:’font-size:small;font-weight:bold;color:gray’,
    aStyle:’font-size:xx-small’,
    a:[‘Pizza’,’Hot dog’,’Hamburger’,’Neither of them’], // Leave empty for free input
    aStyle:’font-size:xx-small’,
    color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
    forceLowerCaseAnswer:false, // Group result by lowercase
    chart:’col’, // table, bar, col or pie
    height:100,
    width:450});

    Please help me… 🙂

      1. yes it shows error in

        SCRIPT5009: ‘$’ is undefined
        spjs-utility.js, line 206 character 1

        SCRIPT5009: ‘$’ is undefined
        PollForSharePoint.js, line 94 character 3

        SCRIPT1002: Syntax error
        jquery.min.js, line 1 character 1

        SCRIPT1002: Syntax error
        jquery.min.js, line 1 character 1

        SCRIPT5009: ‘$’ is undefined
        PollForSharePoint.js, line 94 character 3

      2. am i missing any settings.. ?? I am new to web parts and sharepoint. Probably i missed out something..

      3. I added the below code through script editor.

        buildQueryWP({pollAnswerListName:’PollList’,
        listBaseUrl:L_Menu_BaseUrl,
        id:’myPoll3′, // Allowed characters id a-z, 0-9 – and _
        start:’10/22/2013′, // format: mm/dd/yyyy
        end:’11/10/2014′, // format: mm/dd/yyyy
        singleResponse:false,
        q:”What is your favorite junk food?”,
        qStyle:’font-size:small;font-weight:bold;color:gray’,
        aStyle:’font-size:xx-small’,
        a:[‘Pizza’,’Hot dog’,’Hamburger’,’Neither of them’], // Leave empty for free input
        aStyle:’font-size:xx-small’,
        color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
        forceLowerCaseAnswer:false, // Group result by lowercase
        chart:’col’, // table, bar, col or pie
        height:100,
        width:450});

      4. Also i tried referencing the Pollbase.js file through content editor. The test link works fine. but i get the same output.

      5. I believe you mean the references to the js files.

        buildQueryWP({pollAnswerListName:’PollList’,
        listBaseUrl:L_Menu_BaseUrl,
        id:’myPoll3′, // Allowed characters id a-z, 0-9 – and _
        start:’10/22/2013′, // format: mm/dd/yyyy
        end:’11/10/2014′, // format: mm/dd/yyyy
        singleResponse:false,
        q:”What is your favorite junk food?”,
        qStyle:’font-size:small;font-weight:bold;color:gray’,
        aStyle:’font-size:xx-small’,
        a:[‘Pizza’,’Hot dog’,’Hamburger’,’Neither of them’], // Leave empty for free input
        aStyle:’font-size:xx-small’,
        color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
        forceLowerCaseAnswer:false, // Group result by lowercase
        chart:’col’, // table, bar, col or pie
        height:100,
        width:450});

      6. src=”http://c4968397007/sites/SiteColl1/SiteAssets/PollForSharePoint.js”
        src=”http://c4968397007/sites/SiteColl1/SiteAssets/spjs-utility.js”

        I have added this references to the pollbase script.. as was mentioned in the steps

      7. Hi Alex, No it is still showing the same error.
        The error points to below line of pollforsharepoint.js

        $.each(argObj.a,function(i,answer)

      8. I added alerts to the pollforsharepoint.js it referencing to the file. Also question.submit button are viewed but only answer radio buttons are not working.

      9. Hi Alex,
        it worked fine after installing few plugins…. also i m able to customize.. Now i need to add labels to the bars…
        For eg. the bars above would have labels ham,pizza,hot dog on it.
        It would be very helpful if you could help me up 🙂

      10. Hi,
        I do not think this is possible. You can use the pie chart as this has labels.

        Please note that the Google Image charts will stop working April 20, 2015 as it has been deprecated.

        Alexander

  62. Brother Alexander,

    I am using this with sharepoint2013 it displays ok and working fine, only one thing is not working, if I enable singleResponse:true, it shows me the submit button with only the question and result link and this button doing nothing if I press.

    singleResponse:false working fine but I need singleResponse:true so only one time response from the user, please guide me.

    this is my code

    buildQueryWP({pollAnswerListName:’4079D6A1-6679-45EB-8CDF-EC37AC292C22′,
    listBaseUrl:’/sites/boardmeeting’,
    id:’4079d6a1-6679-45eb-8cdf-ec37ac292c22′, // Allowed characters id a-z, 0-9 – and _
    start:’01/25/2014′, // format: mm/dd/yyyy
    end:’02/05/2014′, // format: mm/dd/yyyy
    singleResponse:true,
    q:”What is your favorite junk food?”,
    qStyle:’font-size:small;font-weight:bold;color:gray’,
    aStyle:’font-size:xx-small’,
    a:[‘Pizza’,’Hot dog’,’Hamburger’,’Neither of them’], // Leave empty for free input
    aStyle:’font-size:xx-small’,
    color:[’32CD32′,’FFCC11′,’FF3300′,’C0C0C0′],
    forceLowerCaseAnswer:false, // Group result by lowercase
    chart:’col’, // table, bar, col or pie
    height:100,
    width:450});

  63. Hey Alex, Great solution. I’ve implemented it successfully.
    Is there an option to show the chart first when a user accesses the page with the CEWP? (Without having to click ‘Show Result’ )

    Thanks you

    1. Hi,
      There is no built in option to control this, but you can do it “manually” by calling this function below the “buildQueryWP” call:

      showResults("Poll_3");

      “Poll_3” is the ID of the poll.

      To have both the result and the poll visible, add this to the code:

      showResults("Poll_3");
      $("#insertPollHere_Poll_3").show();
      $("#Poll_result_Poll_3").hide();
      $("#pollResult_Poll_3").find("div:first").hide();
      $("#Poll_back_Poll_3").hide();

      Alexander

  64. Poll is working: but not able to get the graphs. Submit and View Results links showing the below error on console in SharePoint 2013
    Object doesn’t support property or method ‘filterNode’.

    Please advice.

  65. Hi,

    What will happen when the google api stops working in april 2015? Will you update to an updated api or will you discontinue this “product”? Thanks for amazing work!

    1. I will update it to use visualization api rather than the image charts. I have a lot on the agenda though, so you might want to remind me again in the start of 2015 if I have not already made the change.

      Alexander

  66. Hi Alexander,

    This is a great bit of code and exactly what we needed for our intranet, thank you 🙂

    I, for one, will definitely be interested in an update that replaces the deprecated Google Image charts.

    Thanks again
    Glenn

  67. Hi – thanks for this, been using for a while! Strangely though on my instances the ‘show results’ link just stopped working sometime this week. Poll still works and results can be seen in the list, just the ‘show result’ link not working……anyone else noticed this?

  68. Hi Alexander,

    Thank you very much for your grate solution. I tried implementing it in our site and it’s working very fine. I though have concern if possible to have 2 questions in single poll?

    Thanks.

  69. Hi Alex

    If using the table/text format only for output, will the poll continue to work after April 20 2015?

    1. Yes,
      And I do have plans to fix it so it will continue to work with charts, but I am to busy to get done right now. If April 20’th is approaching and it is not done, please remind me again and I will get it done.

      Alexander

Comments are closed.