Recently I had a request from a business unit to change the Out of Box wording on a survey that employees were taking from the SharePoint standard of “Specify your own value:” to “Other:” which seemed fairly routine and something that could be done easily with a few lines of JavaScript, a quick Google search turned up some interesting an unique ways of doing this including:

  1. Changing the default.master page to include JavaScript and adding a function call in the body tag
    1. This of course would add a bit of overhead for every single page that uses the master page!
  2. Editing the ows.js file and editing the string
    1. Which works fine until the next update or patch and the ows.js file is overwritten, also never ever modify out of box .js!
  3. Using JQuery to find the exact field attribute (by name) and changing the text
    1. Really?  I need JQuery to do something simple like this?

I saw a couple other methods of achieving these results, all of them very bad, most of which made me cringe because it either went against my core belief that you never modify out of box code, you never add global functionality for specific items, or it goes against the lazy bone that believes everything should just be a simple cut and paste function without customization, if I can’t drop the functionality in as a web part then damn it I should be able to!  So I looked for a better way, surprisingly nobody seemed to hit upon this method, which utilizes our handy and ever trusty Content Editor Web Part…

  1. Open the site in SharePoint Designer 2010
  2. Go to the Lists and Libraries, and select the Survey you want to edit from the content window:
    image
  3. Click on the “NewForm.aspx” file in your main content window:
    image
  4. Now add a Content Editor Web Part right below the standard ListFormWebPart, like so…
    image

Now, as for the content, it gets a bit tricky, you’ll want to go down to where the <Content> tag is for your Content Editor Web Part and add the following code between the brackets in the CDATA[]

<span style="text-decoration: line-through;">&lt;script type=<span class="str">"text/javascript"</span>&gt;
     var labels = document.getElementsByTagName(<span class="str">"label"</span>);
     <span class="kwrd">for</span>(var i = 0; i &lt; labels.length; i++)
     {
            <span class="kwrd">if</span>(labels[i].innerText == <span class="str">"Specify your own value:"</span>)
                 labels[i].innerText = <span class="str">"Other:"</span>;
     }
&lt;/script&gt;</span>

EDIT: As you may see from the comments, I forgot about FireFox, so for those of you who like cut and paste, use the script below instead in order to work with FireFox as well by replacing the “innerText” with “innerHTML”

<span class="kwrd">&lt;</span><span class="html">script</span> <span class="attr">type</span><span class="kwrd">="text/javascript"</span><span class="kwrd">&gt;</span>
     <span class="kwrd">var</span> labels = document.getElementsByTagName(<span class="str">"label"</span>);
     <span class="kwrd">for</span>(<span class="kwrd">var</span> i = 0; i &lt; labels.length; i++)
     {
            <span class="kwrd">if</span>(labels[i].innerHTML == <span class="str">"Specify your own value:"</span>)
                 labels[i].innerHTML = <span class="str">"Other:"</span>;
     }
<span class="kwrd">&lt;/</span><span class="html">script</span><span class="kwrd">&gt;</span>

 

It should look like the following on your screen:

image

  1. Ok, save the NewForm.aspx page and you’re done.  Now when a user goes to take the survey, the ugly “Specify your own value:” is replaced with a nice friendly “Other:”image
  2. Even better, because we used SharePoint web parts to achieve this, we only experience overhead on this specific page, we didn’t have to edit out of box code, and because we stayed within the normal confines of editing the NewForm.aspx it means our file doesn’t get UnGhosted!  Winner!image