Add Image to SP2010 Survey


The out-of-the box survey in SharePoint makes it possible to quickly set up surveys.
However, when it comes to special stuff like adding images to the survey you have to purchase an add-on or develop something yourself.
Here I found a quick script that lets you replace a string text with an image. I only needed one, so you have to further develop for more images…

Add a question to the Survey with a textbox. As question type “image1″ as default value for the textbox put in “No input”. The textbox with “No input” will be hidden.
The script below also removes the “Save and Close button” from all questions.

<script type="text/javascript" language="javascript">

var className;
className = 'ms-formlabel';
var elements = new Array();
var elements = document.getElementsByTagName('td');
for (var e = 0; e < elements.length; e++)
if (elements[e].className == className)
elements[e].innerHTML = elements[e].innerHTML.replace('image1','<img src=""></img>');

 // hide page items 
var inputs = document.getElementsByTagName("input");  
      for(var i = 0; i < inputs.length; i++)  
            //hide No input textbox
            if(inputs[i].value == "No input")   
            inputs[i].style.display = 'none';  
            //hide Save and Close button
            if(inputs[i].value=='Save and Close')

FYI To be able to add the Content Editor Webpart to the Survey page. Open the Survey, right click – Properties, and copy the source URL to a new browser window. That will open the survey page with all controls in the bowser and you can add webparts. Some controls are still unusable so you might have to further configure it in SharePoint Designer.

The entire survey consists of 2 aspx files. The first page is in the “NewForm.aspx” and the entire rest of the questions are in the “EditForm.aspx”. So you have to also apply the script to both aspx files!

PS: I had a hell of a time to get the script to work. Then when I moved it to the bottom of the page it worked like a charm! Urghh


Is this Pages usefull? Usefull Useless 0 of 0 people say this Pages is usefull.