Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hi @ll,

weiß jemand von euch eine Möglichkeit eine HTML-Tabelle aufsteigend zu sortieren, wenn man die jeweilige Überschrift klickt. Soll heißen, ich habe eine Tabelle, die wie folgt aussieht:

<table>

 <tr>

  <th>Name</th>

  <th>Funktion</th>

  <th>Raum</th>

  <th>Telefonnummer</th>

 </tr>

 <tr>

  <td>Name2</td>

  <td>Funktion11</td>

  <td>Raum4</td>

  <td>Telefonnummer3</td>

 </tr>

 <tr>

  <td>Name1</td>

  <td>Funktion13</td>

  <td>Raum3</td>

  <td>Telefonnummer2</td>

 </tr>

 <tr>

  <td>Name3</td>

  <td>Funktion1</td>

  <td>Raum8</td>

  <td>Telefonnummer1</td>

 </tr>

</table>
Wenn ich jetzt auf Name klicke, soll die Tabelle nach Namen sortiert werden:
<table>

 <tr>

  <th>Name</th>

  <th>Funktion</th>

  <th>Raum</th>

  <th>Telefonnummer</th>

 </tr>

 <tr>

  <td>Name1</td>

  <td>Funktion13</td>

  <td>Raum3</td>

  <td>Telefonnummer2</td>

 </tr>

 <tr>

  <td>Name2</td>

  <td>Funktion11</td>

  <td>Raum4</td>

  <td>Telefonnummer3</td>

 </tr>

 <tr>

  <td>Name3</td>

  <td>Funktion1</td>

  <td>Raum8</td>

  <td>Telefonnummer1</td>

 </tr>

</table>

Und das für jede der 4 Überschriften. Mir ist spontan eingefallen, das mit einem Javascript zu lösen. Ich geb den Zeilen IDs und frage dann im J-Script ab. Nur wie ich dann neu sortiere und anzeigen lasse versteh ich noch nicht. Gibt es da vllt eine automatisierte Variante? Kann man das auch einfacher lösen? Wenn jemand bereits so etwas geschrieben hat, wäre ich über Beispiele oder ein fertiges Script sehr froh.

hier findest du ein kleines Tutorial wie man Bubblesort (Sortierverfahren) in JS einbindet.

Sollte das schwer zu verstehen sein, google mal nach "Bubblesort javascript" da gibts tausende, auch mit anderen "Sortierverfahren Javascript"

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.