JavaScript and SPFieldChoice (value) RRS feed

  • Question

  • Hey,


    I have a SharePoint list with an field „yes or no“ as radio button (FieldType="SPFieldChoice"). The field is called “Test”.

    Now I have to write an JavaScript function: if the field “Test” changes to “yes” the field “Test reason” is show up.

    How I can read the value of the field “Test” with JavaScript?


    Thanks for your help.



    Viele Grüße Stefan
    Tuesday, May 31, 2011 7:57 AM

All replies

  • Hi


    I understand that you have a SPFieldChoice field in a list .You want to read the value of the field using JavaScript.


    Here  is a similar request ,you can refer to these sites for more detailed information:

    Get the value from SPFiledChoice: http://social.msdn.microsoft.com/forums/en-US/sharepointdevelopment/thread/20d0f989-1b68-49ab-b47f-e4308a1982d9/

    Retrieving values from SPField objects, not item.ToString(): http://gemsolution.blogspot.com/2008/04/retrieving-values-from-spfield-objects.html


    If there is anything unclear ,please feel free to ask .



    Regards, Rock Wang Microsoft Online Community Support
    Tuesday, May 31, 2011 11:19 AM
  • function findacontrol(FieldName) {
      var arr = document.getElementsByTagName("!");
      // get all comments
      for (var i=0;i < arr.length; i++ )
       // now match the field name
       if (arr[i].innerHTML.indexOf(FieldName) > 0)
       {     return arr[i];   }
    function getField(fieldType,fieldTitle) {
      var docTags = document.getElementsByTagName(fieldType);
      for (var i=0; i < docTags.length; i++) {
        if (docTags[i].title == fieldTitle) {
          return docTags[i]
    function Main() {
    alert(getField( 'select','Test').toString());




    This is what I have now. But it brings me an error (Meldung: 'undefined' ist Null oder kein Objekt).


    Thank Rock-Wong for your help.

    Viele Grüße Stefan
    Tuesday, May 31, 2011 12:39 PM