templates/twig/search.html
changeset 23 2d22262da8e0
parent 3 6d109e3804ac
equal deleted inserted replaced
20:52fb6408b86a 23:2d22262da8e0
       
     1 <html>
       
     2 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       
     3 <head>
       
     4 
       
     5 <script type=text/javascript>
       
     6     // source: http://de.wikibooks.org/wiki/Websiteentwicklung:_AJAX:_Erstes_Programm
       
     7     var _ajax;
       
     8     
       
     9     function got_answer() {
       
    10 	if (_ajax.readyState == 4 && _ajax.status == 200) {
       
    11 	    document.getElementById('result').innerHTML = _ajax.responseText;
       
    12 	}
       
    13     }
       
    14 
       
    15     function search_entries(value) {
       
    16 	value = encodeURIComponent(value);
       
    17 	request = "?action=search&format=table&max=3&pattern=" + value;
       
    18 	_ajax = new XMLHttpRequest();
       
    19 	_ajax.onreadystatechange = got_answer;
       
    20 	_ajax.open("GET", request, true);
       
    21 	_ajax.send();
       
    22     }
       
    23 </script>
       
    24 
       
    25 <style type="text/css">
       
    26 	form label { display:block; float:left; width:10ex; }
       
    27 </style>
       
    28 
       
    29 </head><body>
       
    30 
       
    31 [ <a href="?action=add">Add Entries</a> ]
       
    32 
       
    33 <h1>Adressbuch</h1>
       
    34 
       
    35 	<form autocomplete=off>
       
    36 	<label for=pattern>Suche</label>
       
    37 	<input  id=pattern type=text name=pattern 
       
    38 	    onKeyUp="search_entries(this.value)" 
       
    39 	    onChange="submit()") />
       
    40 	<input type=hidden name=action value=search autocomplete=off />
       
    41 	<noscript><input type=submit /></noscript>
       
    42 	</form>
       
    43 
       
    44 	<div id=result>
       
    45 	    {% include "results.html" %}
       
    46 	</div>
       
    47 
       
    48 </body>