• Sharepoint Survey: Can I add a comment box to a question?

    by  • March 2, 2010 • MOSS 2007 • 4 Comments

    Recently, there was an interesting question in stackoverflow

    I am doing a survey in SharePoint, using the built in survey tool.

    I want to add a comment box next to my “ratings” questions. e.g.

    Q1. Do you like fish?

    1. Not at all
    2. They’re alright
    3. I love fish!

    Comment:

    How can I do this all within one question? I can obviously add a new text question, but this will become Q2, and I want it to be part of the same question.

    Any idea how I can do this?

    By default SharePoint does not give us this option. So how can you do this? Here is a work around.

    1. Add a Question, with Text box, below the question under which you need this comment box.
    2. Edit the Newform.aspx page and insert a content editor webpart in the below of existing survey webpart.
    3. Copy and paste the below code in the content editor webpart
    <script>
    var tables
    tables = (document.getElementById('ctl00_m_g_c7647c31_a9f9_4f27_aa53_e0728c485b2c_ctl00_ctl01_ctl00_ctl00_ctl00_ctl04_
    ctl00_ctl00_TextField').offsetParent).offsetParent;
    
    var i
    var str
    for(i=0;i<tables.rows.length;i++)
    {
    str = tables.rows[i].cells[0].innerHTML;
    str = str.substring(0,7)
    //alert(str);
    if(str == 'Comment')
    {
    tables.rows[i].cells[0].innerHTML = '<table width=400px border=0><tr><td><font color=blue size=3></font></td></tr></table>';
    
    }
    }
    </script>
    

    In the above code ctl00_m_g_c7647c31_a9f9_4f27_aa53_e0728c485b2c_ctl00_ctl01_ctl00_ctl00_ctl00_ctl04_ctl00_ctl00_TextField is the ID fo the Comment Textbox control. (You can get it by Viewing the Source code of the page).

    All we do is get the container of the Textbox control and hide it. Here is the screenshot of a sample survey

    About

    Hojo Clement was working in US Technology in Trivandrum as a Senior Software Engineer. He has 6 years experience in working with Web Development Technologies inlcuding MOSS and ASP.net.

    4 Responses to Sharepoint Survey: Can I add a comment box to a question?

    1. August 25, 2010 at 8:21 pm

      hey info with regard to this site really helpfull,please visit our site Daily Review

    2. October 10, 2010 at 12:14 pm

      watching just about for the most effective web-site getting 1.

    3. Raja
      November 18, 2010 at 7:22 am

      I need to create a survey in sharepoint 2010.for a single question i need more than one answer type.for example i have a question

      q1) who is tall?

      a)raja
      b)gopal
      c)rajkumar

      Now i need to add another text box below this with an description “Others” to enter an Answer other that of those options listed above.

      can u give me the solution.

    4. Nasser
      April 26, 2011 at 2:29 pm

      Great post.

      Now, how do you achieve the same effect in SharePoint 2010? :)

    Leave a Reply

    Your email address will not be published. Required fields are marked *