SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add some javascript code to my list, but i am not having any luck with it. My goal is to:

  1. page loads no check boxes are checked
  2. when user checks one box a second check box will be checked at the same time and the others will gray out. Can anyone help me with this?

Here is my testing example that i am not having any luck with...

<![CDATA[<script type="text/javascript">
   function enableTextBox() 
        if (document.getElementById("ctl00_m_g_6b2cd800_765f_4cff_860f_53b0a713a6c4_ff61_ctl00_ctl02").checked = true)

        alert("I am an alert box!");


share|improve this question
Are you adding this Javascript in Content Editor Web Part? – Arsalan Adam Khatri Oct 25 '12 at 15:16
In your code you have checked = true which assigns the value of true, it is not a comparison. Use either == or ===. – Robert Kaucher Oct 25 '12 at 18:13

Based on your code I am going to assume that you are a bit new to JavaScript. My suggestion is that you check out the site as they have excellent training on JavaScript development and SharePoint as well as the JavaScript Client Object Model.

For the record I am in no way affiliated with them, I just use and love their service.

Learn the fundamentals of JavaScript and practice with tools like

Here is a JSFiddle with your code that runs when the page loads.

Here is one that uses jQuery to attach to the change event on the radio button.

Please see the tutorials on or on PluralSight for more information on how to use it.

share|improve this answer

Are you calling enableTextBox() anywhere? If not, your code would never be called.

Probably what you want is the onchange event

For basic Javascript questions such as this one, as opposed to Sharepoint client object model or "it works on a plain html page but not in Sharepoint" type questions, Stackoverflow would be a better resource.

share|improve this answer

use jQuery, hosting the jQuery libraries either on the server or on the site locally. You can then either add your own jQuery plugin and call it or call your code directly. Then add a content editor webpart to the list edit form using SharePoint Designer.

An example would be:

<script language="javascript" type="text/javascript" src="/Style Library/jquery-1.8.1.js"></script>
<script language="javascript" type="text/javascript" src="/Style Library/myjquery.projectFile.js"></script>  
<script language="javascript" type="text/javascript">
$(document).ready(function () {
   alert($("input[title='" + "MyFieldsTitle" + "']")attr('CHECKED')); 

Be aware that SharePoint form html is... difficult, therefore a simple Yes/No field uses the adds the html attribute 'CHECKED' with value 'checked' only if the item is checked, otherwise it is simply omitted.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.