[JavaScript] Auswahl aus Liste makieren

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • [JavaScript] Auswahl aus Liste makieren

    Hi

    also folgendes. ich hab ne Große DB mit Firmendaten.

    ich lese nur die Firmennamen aus und klatsche sie in eine Selectlist. Jetzt bräuchte ich eine Funktion die nun automatisch bei einer Eingabe in Feld Firmennamen auf den entsprechenden eintrag springt.

    Ich hoffe, es ist einigermaßen sinnvoll erklärt was ich brauche. Hab auch noch ein Bild angehängt wie ich meine bzw. wie ich es in Delphi mache.


    Ich Danke

    aTriX
    Angehängte Dateien

  • #2
    Re: [JavaScript] Auswahl aus Liste makieren

    Original geschrieben von aTriX
    eine Funktion die nun automatisch bei einer Eingabe in Feld Firmennamen auf den entsprechenden eintrag springt.
    bei änderung im formularfeld (onKeyup würde ich empfehlen) den aktuellen value auslesen, und dann schauen, ob es in den options eine (oder mehrere) gibt, die mit diesem wert anfangen (methode indexOf() des string-objektes) - und dann diese auswählen, über selectedIndex (bei mehreren wohl die erste, d.h. nach dem ersten treffer kann die schleife über die options dann auch abgebrochen werden).

    zu den stichworten einfach mal bei http://de.selfhtml.org/javascript/objekte/ nachschauen, sollte eigentlich nicht allzu kompliziert sein.
    Zuletzt geändert von wahsaga; 25.05.2005, 08:31.
    I don't believe in rebirth. Actually, I never did in my whole lives.

    Kommentar


    • #3
      hi


      Vielen Dank hab schon ne lösung, ich poste sie mal falls jmd intressiert


      PHP-Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
      <
      html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head>
      <
      meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
      <
      title>Test</title>
      <
      script type="text/javascript">
      <!--
      function 
      selectIt()
       { 
      text document.getElementById('choose').value; for(0document.getElementById('sel').lengthi++)
        { if (
      text.toLowerCase()==document.getElementById('sel') .options[i].text .substring(0,text.length).toLowerCase())
        { 
      document.getElementById('sel').selectedIndex=i; break; } } } function selected()
        { 
      text document.getElementById('sel') .options[document .getElementById('sel')
        .
      selectedIndex].textdocument.getElementById('choose').value=text; } -->
        </
      script>
         </
      head> <body>
         <
      h1>HTML-Attribute</h1>
         <
      form action="./" method="post">
         <
      p><input type="text" name="choose" id="choose" onblur="selected()"  style="width:200px;" />
         </
      p> <p><select id="sel" name="sel" size="10" style="width:205px;"  onchange="selected();">
         <
      option>a</option>
         <
      option>abbr</option>
         <
      option>acronym</option>
         <
      option>address</option>
         <
      option>applet</option>
         <
      option>area</option>
         <
      option>b</option>
         <
      option>base</option>
         <
      option>basefont</option>
         <
      option>bdo</option>
         <
      option>big</option>
         <
      option>blockquote</option>
         <
      option>body</option>
         <
      option>br</option>
         <
      option>button</option>
         <
      option>caption</option>
         <
      option>center</option>
         <
      option>cite</option>
         <
      option>code</option>
         <
      option>col</option>
         <
      option>colgroup</option>
         <
      option>dd</option>
         <
      option>del</option>
         <
      option>dfn</option>
         <
      option>dir</option>
         <
      option>div</option>
         <
      option>dl</option>
         <
      option>dt</option>
         <
      option>em</option>
         <
      option>fieldset</option>
         <
      option>font</option>
         <
      option>form</option>
         <
      option>frame</option>
         <
      option>frameset</option>
         <
      option>h1</option>
         <
      option>h2</option>
         <
      option>h3</option>
         <
      option>h4</option>
         <
      option>h5</option>
         <
      option>h6</option>
        <
      option>head</option>
        <
      option>hr</option>
        <
      option>html</option>
        <
      option>i</option>
       </
      select></p>
       </
      form>
       <
      script type="text/javascript"> <!-- document.getElementById('choose').onkeyup selectIt; --> </script> </body> </html

      cya

      Zuletzt geändert von aTriX; 25.05.2005, 09:33.

      Kommentar

      Lädt...
      X