Bonjour à tous,

Depuis 3 jours je travail sur un champ de recherche a auto-compléter (j'ai réalisé plusieurs tuto), depuis hier j'ai presque réussi a tout faire (je suis débutant).

Mon formulaire est simple, il se trouve à l'adresse suivante : http://www.annuaire-des-parfumeries.fr/test.php

Mon code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
<!DOCTYPE html>
<html>
<head>
<title>Votre titre</title>
 
        <!-- inclusion du style CSS de base -->
<meta charset="UTF-8" />
<script src="js/jquery.min.js"></script>	
<script src="js/typeahead.min.js"></script>	
 
</head>
 
 <body>
 
<div id="the-basics">
  <input class="typeahead" type="text" placeholder="States of USA">
</div>	
 
 
<script type="text/javascript">	
 
var substringMatcher = function(strs) {
  return function findMatches(q, cb) {
    var matches, substringRegex;
 
    // an array that will be populated with substring matches
    matches = [];
 
    // regex used to determine if a string contains the substring `q`
    substrRegex = new RegExp(q, 'i');
 
    // iterate through the pool of strings and for any string that
    // contains the substring `q`, add it to the `matches` array
    $.each(strs, function(i, str) {
      if (substrRegex.test(str)) {
        matches.push(str);
      }
    });
 
    cb(matches);
  };
};
 
var states = ['Alabama', 'Alaska', 'Arizona', 'Arkansas', '59160 Lomme', 'California', 'Nîme',
  'Colorado', 'Connecticut', 'Delaware', 'Florida', 'Géorgia', 'Hawaii',
  'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas', 'Kentucky', 'Louisiana',
  'Maine', 'Maryland', 'Massachusetts', 'Michigan', 'Minnesota',
  'Mississippi', 'Missouri', 'Montana', 'Nebraska', 'Nevada', 'New Hampshire',
  'New Jersey', 'New Mexico', 'New York', 'North Carolina', 'North Dakota',
  'Ohio', 'Oklahoma', 'Oregon', 'Pennsylvania', 'Rhode Island',
  'South Carolina', 'South Dakota', 'Tennessee', 'Texas', 'Utah', 'Vermont',
  'Virginia', 'Washington', 'West Virginia', 'Wisconsin', 'Wyoming'
];
 
$('#the-basics .typeahead').typeahead({
  hint: true,
  highlight: true,
  minLength: 1
},
{
  name: 'states',
  source: substringMatcher(states)
});
 
 
</script>		
 
 
</body>
</html>
Mon problème est le suivant : j'aimerais que quand je tape par exemple "nim" le formulaire me propose "Nîme". Ce qui n'ai pas le cas pour l'instant.

J'ai fait le tour des forums, mais j'ai pas trouvé de post pour m'aider.

Merci de votre aide.

Cordialement

Tom