Einzelnen Beitrag anzeigen
  #1  
Alt 13.09.2013, 09:15:49
Tiac Tiac ist offline
Anfänger
 
Registriert seit: Sep 2013
Alter: 41
Beiträge: 4
Hilfe für URL Änderung

Hallo Community,

ich habe eine Filterfunktion für meine Website erstellt. Dabei wird an den URL ein bestimmter Wert und die User Eingabe hinter den bestehenden URL, getrennt mit einem Semikolon gehängt. Um Tippfehler zu vermeiden, habe ich nun eine "Autocomplete" Funktion mit eingebaut. Die Wert werden auch übernommen, allerdings greift der URL jetzt nicht mehr auf diese Werte zu.
Ich weiß, dass die Funktion nun nicht mehr auf "+ textbox.value" zugreift. Allerdings habe ich leider keine Ahnung was ich da jetzt eingeben muss. Schaut euch doch bitte einmal den Code an, vielleicht kann mir jemand von euch helfen.

Code:
<script>
  $(function() {
    var availableTags = [
      "Neu",
      "New",
      "Hallo",
      "Test"
    ];
    function split( val ) {
      return val.split( /;\s*/ );
    }
    function extractLast( term ) {
      return split( term ).pop();
    }
 
    $( "#tags" )
      // don't navigate away from the field on tab when selecting an item
      .bind( "keydown", function( event ) {
        if ( event.keyCode === $.ui.keyCode.TAB &&
            $( this ).data( "ui-autocomplete" ).menu.active ) {
          event.preventDefault();
        }
      })
      .autocomplete({
        minLength: 0,
        source: function( request, response ) {
          // delegate back to autocomplete, but extract the last term
          response( $.ui.autocomplete.filter(
            availableTags, extractLast( request.term ) ) );
        },
        focus: function() {
          // prevent value inserted on focus
          return false;
        },
        select: function( event, ui ) {
          var terms = split( this.value );
          // remove the current input
          terms.pop();
          // add the selected item
          terms.push( ui.item.value );
          // add placeholder to get the comma-and-space at the end
          terms.push( "" );
          this.value = terms.join( "; " );
          return false;
        }
      });
  });
  </script>
</head>
<body>
 

  <label for="tags">Titel: </label>
<input type="text" id="tags" onchange="adjustLink();" />
<a href="#" id="filterLink">Filtern</a>
<script type="text/javascript">
function adjustLink() {
  var link = document.getElementById("filterLink");
  var textbox = document.getElementById("tags");
  link.href = "AllItems.aspx?FilterName=Title&FilterMultiValue=" +textbox.value;
}
</script>

 
 
</body>
</html>
Mit Zitat antworten