SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

Set choice field value using java script :

I have a choice field with values :

When my page loads, my choice column should be selected as "Cancelled"(i don't want to set using OOTB default value option.)

share|improve this question
In which kind of Context, a Form ? Listview? – Ren Hoek Jun 4 '12 at 7:26
ootb list form say, editform.aspx – Monica Jagani Jun 4 '12 at 7:37

Imagine you have the following radio buttons:

<input type="radio" name="color" value="pink" /> Pink 
<input type="radio" name="color" value="black" /> Black  

You can select the radio button using the following jQuery code. Insert this code in EditForm.aspx and you're good to go.

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

<script type="text/javascript">

    var presetValue = "black";

Here is the JS only code:

Refer the JS in the EditForm.aspx:

Try this in your myjs.js file:

 var inputs = document.getElementsByTagName("radio");
 var i = 0;
 for (i = 0; i < inputs.length; i++) {
 var input = inputs[i];
 if ('color') > -1)     
    document.getElementById('pink').checked = false;
    document.getElementById('black').checked = true;
share|improve this answer
can i do it with javascript only.No jquery – Monica Jagani Jun 4 '12 at 8:18
What is the glitch while using jQuery? – Falak Mahmood Jun 4 '12 at 8:23
for the particular requirement i can only use javascript. – Monica Jagani Jun 4 '12 at 8:25
try my updated response. Note, I haven't tested it myself so please feel free to improve it. – Falak Mahmood Jun 4 '12 at 9:13

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.