Fabian Bernecker: Bunnyhop mit Javascript

Beitrag lesen

document.Formname.Feldname.focus();

Es funktioniert zwar, aber nicht so wie es sollte. Der Cursor wird an den Anfang des Textfeldes gesetzt und nicht ans Ende :/ Kannst dir ja mal den Code anschauen. Das array und die Tabelleninhalte werden später aus einer Datenbank ausgelesen werden.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      i18n:domain="plone">

<body>

<div metal:define-macro="kurzwahlbox"
     tal:omit-tag=""
     tal:define="DateTime python:modules['DateTime'].DateTime;
                 current python:DateTime();
                 month python:request.get('month', DateTime().month());
                 year python:request.get('year', DateTime().year());
                 prevMonthTime python:here.getPreviousMonth(month, year);
                 nextMonthTime python:here.getNextMonth(month, year);
                 weeks python:here.portal_calendar.getEventsForCalendar(month=month, year=year);">

<!-- Durchwalindex - Anfang /-->
<!-- Durchwalindex - Java Script /-->

<script language="JavaScript">
<!--
function check()
{
 var eingabe = document.all['eingabe'].value;

var array = new Array("Gabian B.","Fabian B.","Nabian C.");

var i = 0;

for(i=0;i<array.length;i++)
 {
  if(eingabe == array[i].substring(0, eingabe.length))
  {
   ziel = array[i];
  }
 }

window.location.href = "#" + ziel;
 document.all['eingabe'].focus();
 //window.location.href = "#top";
}
/-->
</script>

<!-- Durchwalindex - HTML /-->

<table cellpadding="2" cellspacing="0" border="0" class="calendar" id="thecalendar">

<tr>
        <th>
            Durchwahlindex
        </th>
    </tr>

<tr>
  <td class="weekdays">
   <input type="text" id="eingabe" style="width:140px;" onKeyUp="check();document.all['eingabe'].click();">
  </td>
 </tr>

<tr>
     <td class="noevent">
      <div id="La" style="position:relativ; width:140px; height:50px; z-index:1; overflow: auto;">
       <table border="0">
        <tr>
         <td style="width:100%;">
          <a name="Gabian B.">Gabian B.</a>
         </td>
         <td>
          113
         </td>
        </tr>
        <tr>
         <td style="width:100%;">
          Labian B.
         </td>
         <td>
          154
         </td>
        </tr>
        <tr>
         <td style="width:100%;">
          Labian B.
         </td>
         <td>
          154
         </td>
        </tr>
        <tr>
         <td style="width:100%;">
          <a name="Fabian B.">Fabian B.</a>
         </td>
         <td>
          111
         </td>
        </tr>
        <tr>
         <td style="width:100%;">
          <a name="Nabian C.">Nabian C.</a>
         </td>
         <td>
          121
         </td>
        </tr>
       </table>
   </div>
     </td>
    </tr>

</table>

<!-- Durchwalindex - Ende /-->

</div>

</body>

</html>