Javascript
Résolu
FreeMay
Messages postés
14
Statut
Membre
-
FreeMay Messages postés 14 Statut Membre -
FreeMay Messages postés 14 Statut Membre -
Bonjour,
Qui peut m'aider s'il vous plait?
j'ai créé deux listes déroulantes et une zone de texte.
je veux quand je choisi une option dans la première liste, cette option s'affiche dans la zone de texte. Puis, quand je choisi une option dans la deuxième liste déroulante. cette dernière s'affiche dans la zone de texte( mais sans supprimer la première)
Voilà mon essai.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Changer</title>
</head>
<body>
<p><h1>Mon premier essai</h1></p>
<label>La nature de transaction: </label>
<select id="nat"
onChange="change3(this, 'txt')"
onMouseOut="change1(this, 'txt')" >
<option>Achat</option>
<option>Vente</option>
<option>Location</option>
</select>
<br></br>
<label>La categorie du bien: </label>
<select id="cat"
onChange="change2(this, 'txt')"
onMouseOut="change4(this, 'txt')" >
<option> Maison </option>
<option> Voiture </option>
<option> Terrain </option>
<option> Appartement </option>
</select>
<br></br>
<textarea id ="txt"></textarea>
<script type="text/javascript">
function change1(nat)
{
txt = document.getElementById(txt);
var V1 = nat.selectedIndex;
var C1 = nat.options[V1].innerHTML;
if(txt.value == "")
txt.value = C1;
}
function change2(cat)
{
txt = document.getElementById(txt);
var V2 = cat.selectedIndex;
var C2 = cat.options[V2].innerHTML;
if(txt.value == "")
txt.value = C2;
}
function change3(nat, txt)
{
txt = document.getElementById(txt);
var V1 = nat.selectedIndex;
var C1 = nat.options[V1].innerHTML;
txt.value = C1;
}
function change4(cat, txt)
{
txt = document.getElementById(txt);
var V2 = cat.selectedIndex;
var C2 = cat.options[V2].innerHTML;
txt.value = C2;
}
</script>
</body>
</html>
Merci d'avance.
Qui peut m'aider s'il vous plait?
j'ai créé deux listes déroulantes et une zone de texte.
je veux quand je choisi une option dans la première liste, cette option s'affiche dans la zone de texte. Puis, quand je choisi une option dans la deuxième liste déroulante. cette dernière s'affiche dans la zone de texte( mais sans supprimer la première)
Voilà mon essai.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Changer</title>
</head>
<body>
<p><h1>Mon premier essai</h1></p>
<label>La nature de transaction: </label>
<select id="nat"
onChange="change3(this, 'txt')"
onMouseOut="change1(this, 'txt')" >
<option>Achat</option>
<option>Vente</option>
<option>Location</option>
</select>
<br></br>
<label>La categorie du bien: </label>
<select id="cat"
onChange="change2(this, 'txt')"
onMouseOut="change4(this, 'txt')" >
<option> Maison </option>
<option> Voiture </option>
<option> Terrain </option>
<option> Appartement </option>
</select>
<br></br>
<textarea id ="txt"></textarea>
<script type="text/javascript">
function change1(nat)
{
txt = document.getElementById(txt);
var V1 = nat.selectedIndex;
var C1 = nat.options[V1].innerHTML;
if(txt.value == "")
txt.value = C1;
}
function change2(cat)
{
txt = document.getElementById(txt);
var V2 = cat.selectedIndex;
var C2 = cat.options[V2].innerHTML;
if(txt.value == "")
txt.value = C2;
}
function change3(nat, txt)
{
txt = document.getElementById(txt);
var V1 = nat.selectedIndex;
var C1 = nat.options[V1].innerHTML;
txt.value = C1;
}
function change4(cat, txt)
{
txt = document.getElementById(txt);
var V2 = cat.selectedIndex;
var C2 = cat.options[V2].innerHTML;
txt.value = C2;
}
</script>
</body>
</html>
Merci d'avance.
2 réponses
Voila :
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Changer</title>
<script type="text/javascript">
function rafraichit()
{
document.getElementById('txt').value = document.getElementById('nat').value + ' ' + document.getElementById('cat').value;
}
</script>
</head>
<body>
<p><h1>Mon premier essai</h1></p>
<label>La nature de transaction: </label>
<select id="nat"
onChange="rafraichit()"
onMouseOut="rafraichit()" >
<option>Achat</option>
<option>Vente</option>
<option>Location</option>
</select>
<br></br>
<label>La categorie du bien: </label>
<select id="cat"
onChange="rafraichit()"
onMouseOut="rafraichit()" >
<option> Maison </option>
<option> Voiture </option>
<option> Terrain </option>
<option> Appartement </option>
</select>
<br></br>
<textarea id ="txt"></textarea>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Changer</title>
<script type="text/javascript">
function rafraichit()
{
document.getElementById('txt').value = document.getElementById('nat').value + ' ' + document.getElementById('cat').value;
}
</script>
</head>
<body>
<p><h1>Mon premier essai</h1></p>
<label>La nature de transaction: </label>
<select id="nat"
onChange="rafraichit()"
onMouseOut="rafraichit()" >
<option>Achat</option>
<option>Vente</option>
<option>Location</option>
</select>
<br></br>
<label>La categorie du bien: </label>
<select id="cat"
onChange="rafraichit()"
onMouseOut="rafraichit()" >
<option> Maison </option>
<option> Voiture </option>
<option> Terrain </option>
<option> Appartement </option>
</select>
<br></br>
<textarea id ="txt"></textarea>
</body>
</html>