Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

script de recherche avec double checkbox

1 réponse
Avatar
NyOz
Bonjour à tous, j'ai ce charmant petit script qui me permet grâce à un
formulaire de faire une recherche sur mon site par le biais de google (ce
n'est pas la barre de recherche officielle de google)...:


<head>
<script language="JavaScript">
<!--
//PLF-http://www.jejavascript.net/
function cherch(form) {
var adres =
"http://www.google.com/search?hl=fr&ie=UTF-8&oe=UTF-8&q="+form.q.value
+"+site%3Anyoz.fr&btnG=Recherche+Google&lr="
window.open(adres,'','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
}
//-->
</script>
</head>

<body>
<form><p style="margin-top: 4px">
<input type="text" name="q" size="12" style="font-family: Arial;
font-size: 10px; color: #808080; font-weight: bold; vertical-align: middle;
margin-top: -4" value="Rechercher...">
<input onClick=cherch(this.form) type="image" name="Submit"
src="_private/search_button.jpg" width="19" height="18"></form>
</body>



Mon problème :

En utilisant ces deux checkbox :
<input type="radio" id="ch1" value="V1" checked name="R1">
<input type="radio" id="ch2" name="R1" value="V2">

Je voudrais faire en sorte que si par exemple "ch1" est cochée, que le
javascript recherche sur le site www.nyoz.free.fr
et si "ch2" est cochée, qu'il recherche sur www.nyoz.fr

J'ai essayé en faisant deux scripts séparés et avec des if...else mais ça ne
marche pas...

Commment faire???????


MERCI D'AVANCE !

Nyoz.

1 réponse

Avatar
NyOz
Bon aucune réponse, mais j'ai finit par trouver par moi-même... Pour ceux que
ça interesse :


http://www.editeurjavascript.com/forum/topic,2,42221,0.html

Voila le script sur une page basique :

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Nouvelle page 1</title>
<script>
function RechGoogle(form) {
if (document.getElementById("ch1").checked)
url="http://www.google.com/search?hl=fr&ie=UTF-8&oe=UTF-8&q="+form.q.value
+"+site%3Anyoz.fr&btnG=Recherche+Google&lr=";
else if (document.getElementById("ch2").checked)
url="http://www.google.com/search?hl=fr&ie=UTF-8&oe=UTF-8&q="+form.q.value
+"+site%3Anyoz.free.fr&btnG=Recherche+Google&lr=";
else {
alert("Ben faut faire un choix ...");
return false;
}
window.open(url,'','toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');
}
</script>
</head>

<body>
<form><p style="margin-top: 4px">
<input type="text" name="q" size="12" style="font-family: Arial;
font-size: 10px; color: #808080; font-weight: bold; vertical-align: middle;
margin-top: -4" value="Rechercher...">
<input onClick=RechGoogle(this.form) type="image" name="Submit"
src="_private/search_button.jpg" width="19" height="18"></form>
<input type="radio" id="ch1" value="V1" checked name="R1">
<input type="radio" id="ch2" name="R1" value="V2">
</body>

</html>




:: Nyoz ::