Blog Stats
  • Posts - 40
  • Articles - 0
  • Comments - 28
  • Trackbacks - 0

 

How to find Radio Button (Choice Field ) using JQuery in SharePoint Desinger

How to find Radio Button (Choice Field ) using JQuery in SharePoint Desinger

 <script type="text/javascript" src="/sitecoll/testsite/SiteAssets/Libraries/jquery-1.4.min.js"></script>
 <script  type="text/javascript">
   $(function() {
    var str = $('input[name*=ff200]').get(1).id;
    document.getElementById(str).setAttribute('checked','checked');
  })
</script>
Here we have a Radio button with Yes and No Options.

The XSLT of Radio button in SharePoint is

<SharePoint:FormField runat="server" id="ff200{$Pos}" ControlMode="Edit" FieldName="FeedbackCompleted" __designer:bind="{ddwrt:DataBind('u',concat('ff200',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@FeedbackCompleted')}"/>

 

$('input[name*=ff200]') - It searches the input element whose name contains ff200 which is the in ID of the SharePoint FormField.

var str = $('input[name*=ff200]').get(1).id; line finds the ID of the Element, As radio button has two or more options but in SharePoint it is FormField. So you want to find id of First Radio Button use get(0), Second Radio button use get(1) etc.

and Finally we ON the Radio button using jQuery/JavaScript.

One of the best article I found is

https://www.nothingbutsharepoint.com/sites/eusp/Pages/jquery-to-the-rescue-default-text-based-on-radio-button-click.aspx

 

Thanks- Jayant 


 


Feedback

No comments posted yet.


Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

 

 

Copyright © Jayant Kumar