$(function () { pageContext.i18n.modTalk = 'moderation talk'; pageContext.i18n.replyToComment = 'Reply'; pageContext.i18n.modTalkEmpty = 'moderation talk is empty'; pageContext.url.getModTalk = "/comments/%25ID%25/listModTalk.json"; pageContext.url.possibleCommentRecipients = "/comments/%ID%/possibleRecipients.json"; pageContext.url.commentEdit = '/comments/%25ID%25/edit.html'; pageContext.url.commentView = '/comments/%ID%/view.html'; pageContext.i18n.commentVisibility = { 'full': 'Viewable by all users', 'op': 'Viewable by the original poster', 'mod': 'Viewable by moderators', 'opAndMod': 'Viewable by moderators and the original poster', 'other': 'Advanced visibility', 'dialogTitle': 'Comment visibility', 'selectGroups': 'Visible to groups', 'selectOther': 'Other recipients', 'selectOriginalPoster': 'Original poster', 'selectModerators': 'Moderators', 'selectAssignees': 'Asked to answer users' }; pageContext.i18n.commentMenuLabels = { 'comment-edit': 'comments.menu.edit', 'comment-delete': 'comments.menu.delete', 'comment-convert': 'comments.menu.convert' };pageContext.i18n.answer= { bestAnswer: 'Best Answer', controlBar : { accept: 'Accept', unaccept: 'Unaccept', acceptCommand: 'Accept this answer as correct', cancelAcceptedCommand: 'Remove this answers accepted status' } }; window.croles = { u: false, op: false, m: false, og: false, as: false, ag: false, dc: false, doc: false, eo: false, ea: false }; tools.init({ q: { e: false, ew: false, eo: false, r: false, ro: false, d: false, dow: false, fv: false, c: false, co: false, p: false, tm: false , ms: false, mos: false }, n: { f: false, vf: false, vfo: false, vr: true, vro: true, c: false, co: false, vu: false, vd: false, w: false, wo: false, l: false }, c: { e: false, eo: false, d: false, dow: false, ta: false, tao: false, l: false }, a: { e: false, ew: false, eo: false, d: false, dow: false, a: false, aoq: false, ao: false, tc: false, tco: false, p: false, tm: false }, pc: croles }, { tc: true, nsc: true }); commandUtils.initializeLabels(); }); Skip to Content
avatar image
Former Member

Cannot retreive index of selected radio button

Hi,

I have implemented a RadioButtonGroupByIndex as follow:

String[] monthNames = new String []  {
   "January", "February", "March", "April",
   "May", "June", "July", "August", 
   "September", "October", "November", "December",
};

//1. Create context elements for node "MonthsOfYear"
List monthsOfYear = new ArrayList();
for (int i =  0; i < monthNames.length; ++i) {
   IPrivateMainView.IMonthsOfYearElement month = 
   wdContext.createMonthsOfYearElement();
   month.setMonthName(monthNames<i>);
   monthsOfYear.add(month);
}

//2. Bind node to element list
wdContext.nodeMonthsOfYear().bind(MonthsOfYear);


//set lead selection
 wdContext.nodeMonthsOfYear().setLeadSelection(5);

I have created an onSelect event on the RadioButtonGroupByIndex. I am trying to retreive the index of the selected radio button to enable an edit field. When trying to display the id of the selected radio button, the result is "0" for each one of them. How come the index is not 0 for the first one, 1 for the second... ?

Thanks in advance for your help.

Thibault

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Apr 12, 2010 at 03:42 PM
    int selectedIndex = wdContext.nodeMonthsOfYear().getLeadSelection();
    

    Armin

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      You might also change your code to

      String[] monthNames = new String []  {
         "January", "February", "March", "April",
         "May", "June", "July", "August", 
         "September", "October", "November", "December",
      };
       
      for (int i =  0; i < monthNames.length; ++i) 
      {
         IPrivateMainView.IMonthsOfYearElement e =  wdContext.createAndAddMonthsOfYearElement();
         e.setMonthName(monthNames<i>);
      }
      

      and put it into a supply function for the context node.

      Armin

  • Apr 12, 2010 at 01:46 PM

    Hi Thibault,

    Please try this :

    IPrivateMainView.IMonthsOfYearElement month = null;

    for (int i = 0; i < monthNames.length; ++i)

    {

    month = wdContext.createMonthsOfYearElement();

    month.setMonthName(monthNames<i>);

    wdContext.nodeMonthsOfYear().addElement(month);

    }

    //set lead selection

    wdContext.nodeMonthsOfYear().setLeadSelection(5);

    Hope it helps

    Regards

    Arun

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Arun Jaiswal

      In fact this is not the way I would do it. I have associated an event on the redioButtonGroupByIndex. When a user click on one of the buttons, the onActionSelected function is called. Its parameters are the event and the radio button key. When trying to display this key, its value is 0 for each button...