3 Replies Latest reply on Jun 18, 2010 6:06 AM by Eswara MoorthyNEC

    How to set cursor focus to <h:selectOneRadio> during onload?

    Eswara MoorthyNEC Newbie

      Hi,

       

           I need to set cursor focus to radio button during the page loading.

       

       

      <f:view>
          <html>
              <head>
                  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">                                                                    
              </head>
              <body>
                  <h:form id="focusForm" >
                      <h:selectOneRadio id="testRadioId" value="">
                          <f:selectItem id="si1" itemLabel="JSF" />
                          <f:selectItem id="si2" itemLabel="JSP" />
                      </h:selectOneRadio>
                  </h:form>
              </body>
          </html>
      </f:view>
      

       

      I use firebug. The first item id is :  focusForm:testRadioId:0.

      So i wrote script

       

       

      document.getElementById("focusForm:testRadioId:0").focus();
      

       

      I think this is hard code.

      Is any otherway to set focus to the radio field.

      Help me about this.

      Thanks in advance.