title: How can I set focus to Edit Box inside repeat control?
body: <p>I would like to set focus + place cursor to an Edit Box (the last one) within a repreat control. The repeat is inside a panel (panelRep). I then have a button outside the panel.</p>
  
  <p>This is the client side code for the button which almost works.. Focus is set (blue border around field), but cursor is not placed in field.
  User must still click the field to be able to write input.</p>
  
  <p>Example without focus:<br>
  <img src="https://i.stack.imgur.com/31gJW.png" alt="without focus"> </p>
  
  <p>Example with focus:<br>
  <img src="https://i.stack.imgur.com/i7xt9.png" alt="with focus"></p>
  
  <p>Client side code for button which sets focus to last Edit Box in which id contains the string inputKode:</p>
  
  <pre class="lang-js prettyprint-override"><code>try {
  var el = dojo.query('div[id*="inputKode"]');
  var node = el[el.length-1];
  setTimeout(function() { node.focus(); }, 500);
  //node.focus();
  } catch (e) { } 
  </code></pre>
  
  <p>Code for panelRep:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;xp:panel id="panelRep"&gt;
              &lt;xp:repeat id="repeat1" rows="12" var="row" indexVar="idx"
                  value="#{view1}" repeatControls="false"&gt;
                  &lt;xp:panel id="panelLinje"&gt;
                      &lt;xp:this.data&gt;
                          &lt;xp:dominoDocument formName="frmPBudKodeVerdi"
                              var="dsdoc" action="editDocument" computeWithForm="both"
                              documentId="#{javascript:row.getUniversalID();}"&gt;                           
                          &lt;/xp:dominoDocument&gt;
                      &lt;/xp:this.data&gt;
                      &lt;xp:table style="width:800.0px"&gt;
                          &lt;xp:tr&gt;
                              &lt;xp:td style="width:100px"&gt;
                                  &lt;xp:inputText id="inputKode"
                                      value="#{dsdoc.KodeNr}" style="width:62px"&gt;
                                      &lt;xp:this.attrs&gt;
                                          &lt;xp:attr name="tabindex"
                                              value="#{javascript:return idx + '1';}"&gt;
                                          &lt;/xp:attr&gt;
                                      &lt;/xp:this.attrs&gt;
                                      &lt;xp:typeAhead mode="partial"
                                          minChars="1" var="lukey" valueMarkup="true" id="typeAhead1"&gt;
                                          &lt;xp:this.valueList&gt;&lt;![CDATA[#{javascript://var type = compositeData.type;
                                          return TypeAheadKode2(sessionScope.type,lukey);
                                          }]]&gt;&lt;/xp:this.valueList&gt;    
                                      &lt;/xp:typeAhead&gt;
                                      &lt;xp:eventHandler event="onchange"
                                          submit="true" refreshMode="partial" refreshId="panelLinje"&gt;
                                          &lt;xp:this.action&gt;&lt;![CDATA[#{javascript:onChangeKode();}]]&gt;&lt;/xp:this.action&gt;
                                      &lt;/xp:eventHandler&gt;
                                  &lt;/xp:inputText&gt;                             
                              &lt;/xp:td&gt;
                              &lt;xp:td style="width:450px"&gt;
                                  &lt;xp:inputText id="inputNavn"
                                      value="#{dsdoc.KodeNavn}" style="width:440px"
                                      readonly="true"&gt;
                                  &lt;/xp:inputText&gt;
                              &lt;/xp:td&gt;
                              &lt;xp:td style="width:60px"&gt;
                                  &lt;xp:inputText id="inputNorm"
                                      style="width:45px" value="#{dsdoc.NormPrProd}"
                                      rendered="#{javascript:viewScope.visNorm}" readonly="true"&gt;
                                      &lt;xp:this.attrs&gt;
                                          &lt;xp:attr name="tabindex"
                                              value="#{javascript:return idx + '2';}"&gt;
                                          &lt;/xp:attr&gt;
                                      &lt;/xp:this.attrs&gt;
                                      &lt;xp:this.converter&gt;
                                          &lt;xp:convertNumber
                                              type="number"&gt;
                                          &lt;/xp:convertNumber&gt;
                                      &lt;/xp:this.converter&gt;
                                  &lt;/xp:inputText&gt;
                              &lt;/xp:td&gt;
                              &lt;xp:td style="width:50px"&gt;
                                  &lt;xp:inputText id="inputAntall"
                                      style="width:45px" value="#{dsdoc.NormAntall}"
                                      rendered="#{javascript:viewScope.visNorm}"&gt;
                                      &lt;xp:this.converter&gt;
                                          &lt;xp:convertNumber
                                              type="number"&gt;
                                          &lt;/xp:convertNumber&gt;
                                      &lt;/xp:this.converter&gt;
                                      &lt;xp:eventHandler
                                          event="onchange"
                                          submit="true"
                                          refreshMode="partial"
                                          refreshId="inputTimer"&gt;
                                          &lt;xp:this.action&gt;&lt;![CDATA[#{javascript:onChangeAntall()}]]&gt;&lt;/xp:this.action&gt;
                                      &lt;/xp:eventHandler&gt;
                                      &lt;xp:this.attrs&gt;
                                          &lt;xp:attr name="tabindex"
                                              value="#{javascript:return idx + '3';}"&gt;
                                          &lt;/xp:attr&gt;
                                      &lt;/xp:this.attrs&gt;
                                  &lt;/xp:inputText&gt;
                              &lt;/xp:td&gt;
                              &lt;xp:td
                                  style="width:50px;text-align:right"&gt;
                                  &lt;xp:inputText id="inputTimer"
                                      value="#{dsdoc.Timer}" style="width:45px;text-align:right"&gt;
                                      &lt;xp:this.converter&gt;
                                          &lt;xp:convertNumber
                                              type="number"&gt;
                                          &lt;/xp:convertNumber&gt;
                                      &lt;/xp:this.converter&gt;
                                      &lt;xp:this.attrs&gt;
                                          &lt;xp:attr name="tabindex"
                                              value="#{javascript:return idx + '4';}"&gt;
                                          &lt;/xp:attr&gt;
                                      &lt;/xp:this.attrs&gt;
                                  &lt;/xp:inputText&gt;
                              &lt;/xp:td&gt;
                              &lt;xp:td&gt;                             
                              &lt;/xp:td&gt;
                          &lt;/xp:tr&gt;
                      &lt;/xp:table&gt;
                      &lt;xp:eventHandler event="onClientLoad" submit="true"
                          refreshMode="norefresh"&gt;
                      &lt;/xp:eventHandler&gt;
                  &lt;/xp:panel&gt;
              &lt;/xp:repeat&gt;
  &lt;/xp:panel&gt;
  </code></pre>