Validation par entrée dans un formulaire recherche
Bonjour,
J'ai un formulaire de recherche en javascript qui marche voila le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| <code>
<script type="text/javascript" src="recherche.js">
<form method="post" name="log1" action="" >
<input type="text" class="text" name="T1" value="" style="width: 200px;" />
<select class="options" name="D1" style="width: 200px;">
<option value="y">Musique</option>
<option value="s">Paroles de chansons</option>
<option value="r">Vidéos-clips</option>
<option value="l">Téléchargement (MP3)</option>
<option value="d">Actualités</option>
<option value="k">Interviews</option>
</select>
<img border="0" src="http://www.ournia.com/templates/xhtml/form-recherche/recherche.gif" title="Search" onClick="search()" style="cursor:hand">
</form>
</code> |
Recherche.js
Code:
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
| var g,ch;
function search()
{
g=document.log1.T1.value;
ch=document.log1.D1.value;
if(g=='' || g==null){
alert("Saisissez un mot-clé pour effectuer une recherche!");
document.log1.T1.focus();
}else{
if(ch=="y")
window.location="http://www.ournia.com/search.php?search_query=" + g + "&search_do_advanced=1&search_cid[]=0";
if(ch=="s")
window.location="http://www.ournia.com/paroles/search.php?c=" + g;
if(ch=="r")
window.location="http://www.ournia.com/video/clip-" + g + ".html";
if(ch=="l")
window.location="http://www.ournia.com/mp3/" + g + ".html";
if(ch=="d")
window.location="http://www.ournia.com/search.php?search_query=" + g + "&search_do_advanced=1&search_cid[]=2";
if(ch=="k")
window.location="http://www.ournia.com/search.php?search_query=" + g + "&search_do_advanced=1&search_cid[]=31";
}
}
var sto="Click here to download the font required by my site!"
var sta="Done" |
Il marche mais il ya un petit problème quand on ecrit un mot et en valide par entrée sa ne donne rien .
Il faut obligatoirement cliquer sur l'image rechercher!
Merci de me donner une modification de telle sorte que quand:
- On tape un mot clé puis on valide par entrée sa effectue la recherche
-On tape un mot clé et on choisit un type de recherche puis on valide par entrée sa effectue la recherche.
Merci beaucoup