Aide code javascript
Résolu
sniper74
Messages postés
8
Statut
Membre
-
sniper74 Messages postés 8 Statut Membre -
sniper74 Messages postés 8 Statut Membre -
Bonjour,
j'ai un souci avec mon code quand je le mets une fois dans la page web il fonctionne et quand je fais un copier collé pour avoir un deuxieme sa fonctionne pas parcontre j'ai fait une modif a l'interieur en changeant les titres etccc
et sa fonctionne parcontre sa me fait rajouter autant de code script que de balise y aurait 'il moyen de faire une boucle à partir du script
voici le code script javascript
<script>
function Choisir(){
var indice_selectionne=document.Raidoweb.playlist.selectedIndex;
var chango=document.Raidoweb.playlist.options[indice_selectionne].value; switch (chango){
case "Choisir ton titre":document.Raidoweb.Titre.value="";break;
case "Akon Lonely":document.Raidoweb.Titre.value="Akon Lonely";break;
case "Bbp Candy Shop":document.Raidoweb.Titre.value="Bbp Candy Shop";break;
case "Breeze Vs Lost Witness Rise Again":document.Raidoweb.Titre.value="Breeze Vs Lost Witness Rise Again";break;
case "Caramell Caramelldansen":document.Raidoweb.Titre.value="Caramell Caramelldansen";break;
case "Coone And Ghost Pitch Up":document.Raidoweb.Titre.value="Coone And Ghost Pitch Upp";break;
}
}
</script>
<script>
function Choisir1(){
var indice_selectionne=document.Raidoweb1.playlist1.selectedIndex;
var chango=document.Raidoweb1.playlist1.options[indice_selectionne].value; switch (chango){
case "Choisir ton titre":document.Raidoweb1.Titre1.value="";break;
case "1":document.Raidoweb1.Titre1.value="Akon Lonely";break;
case "2":document.Raidoweb1.Titre1.value="Bbp Candy Shop";break;
case "3":document.Raidoweb1.Titre1.value="Breeze Vs Lost Witness Rise Again";break;
case "4":document.Raidoweb1.Titre1.value="Caramell Caramelldansen";break;
case "5":document.Raidoweb1.Titre1.value="Coone And Ghost Pitch Upp";break;
}
}
</script>
le code php html
<table cellspacing="0" cellpadding="0">
<tr>
<td rowspan="5" valign="top" nowrap="nowrap"><img src="Dance-Mania-Party.jpg" alt="titre3" width="100" height="100" /></td>
<td width="35%" valign="top" nowrap="nowrap"><div align="left">
<label></label>
<form name="Raidoweb">
<select name="playlist" onchange="Choisir()">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="Akon Lonely">Akon Lonely</option>
<option value="Bbp Candy Shop">Bbp Candy Shop</option>
<option value="Breeze Vs Lost Witness Rise Again">Breeze Vs Lost Witness Rise Again</option>
<option value="Caramell Caramelldansen">Caramell Caramelldansen</option>
<option value="Coone And Ghost Pitch Up">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre" size="32" value="" type="text" /></form>
</div></td>
<td width="35%" valign="top" nowrap="nowrap"><label></label></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Année sorti : (2008) </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><span property="dc:content">genre: Dance </span></td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Titre : Dance Mania Party</td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"> </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
</table>
<br />
<br />
<table cellspacing="0" cellpadding="0">
<tr>
<td rowspan="5" valign="top" nowrap="nowrap"><img src="Dance-Mania-Party.jpg" alt="titre3" width="100" height="100" /></td>
<td width="35%" valign="top" nowrap="nowrap"><div align="left">
<label></label>
<form name="Raidoweb1">
<select name="playlist1" onchange="Choisir1()">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="1">Akon Lonely</option>
<option value="2">Bbp Candy Shop</option>
<option value="3">Breeze Vs Lost Witness Rise Again</option>
<option value="4">Caramell Caramelldansen</option>
<option value="5">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre1" size="32" value="" type="text" /></form>
</div></td>
<td width="35%" valign="top" nowrap="nowrap"><label></label></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Année sorti : (2008) </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><span property="dc:content">genre: Dance </span></td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Ttitre : Dance Mania Party</td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"> </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
</table>
j'ai un souci avec mon code quand je le mets une fois dans la page web il fonctionne et quand je fais un copier collé pour avoir un deuxieme sa fonctionne pas parcontre j'ai fait une modif a l'interieur en changeant les titres etccc
et sa fonctionne parcontre sa me fait rajouter autant de code script que de balise y aurait 'il moyen de faire une boucle à partir du script
voici le code script javascript
<script>
function Choisir(){
var indice_selectionne=document.Raidoweb.playlist.selectedIndex;
var chango=document.Raidoweb.playlist.options[indice_selectionne].value; switch (chango){
case "Choisir ton titre":document.Raidoweb.Titre.value="";break;
case "Akon Lonely":document.Raidoweb.Titre.value="Akon Lonely";break;
case "Bbp Candy Shop":document.Raidoweb.Titre.value="Bbp Candy Shop";break;
case "Breeze Vs Lost Witness Rise Again":document.Raidoweb.Titre.value="Breeze Vs Lost Witness Rise Again";break;
case "Caramell Caramelldansen":document.Raidoweb.Titre.value="Caramell Caramelldansen";break;
case "Coone And Ghost Pitch Up":document.Raidoweb.Titre.value="Coone And Ghost Pitch Upp";break;
}
}
</script>
<script>
function Choisir1(){
var indice_selectionne=document.Raidoweb1.playlist1.selectedIndex;
var chango=document.Raidoweb1.playlist1.options[indice_selectionne].value; switch (chango){
case "Choisir ton titre":document.Raidoweb1.Titre1.value="";break;
case "1":document.Raidoweb1.Titre1.value="Akon Lonely";break;
case "2":document.Raidoweb1.Titre1.value="Bbp Candy Shop";break;
case "3":document.Raidoweb1.Titre1.value="Breeze Vs Lost Witness Rise Again";break;
case "4":document.Raidoweb1.Titre1.value="Caramell Caramelldansen";break;
case "5":document.Raidoweb1.Titre1.value="Coone And Ghost Pitch Upp";break;
}
}
</script>
le code php html
<table cellspacing="0" cellpadding="0">
<tr>
<td rowspan="5" valign="top" nowrap="nowrap"><img src="Dance-Mania-Party.jpg" alt="titre3" width="100" height="100" /></td>
<td width="35%" valign="top" nowrap="nowrap"><div align="left">
<label></label>
<form name="Raidoweb">
<select name="playlist" onchange="Choisir()">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="Akon Lonely">Akon Lonely</option>
<option value="Bbp Candy Shop">Bbp Candy Shop</option>
<option value="Breeze Vs Lost Witness Rise Again">Breeze Vs Lost Witness Rise Again</option>
<option value="Caramell Caramelldansen">Caramell Caramelldansen</option>
<option value="Coone And Ghost Pitch Up">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre" size="32" value="" type="text" /></form>
</div></td>
<td width="35%" valign="top" nowrap="nowrap"><label></label></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Année sorti : (2008) </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><span property="dc:content">genre: Dance </span></td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Titre : Dance Mania Party</td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"> </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
</table>
<br />
<br />
<table cellspacing="0" cellpadding="0">
<tr>
<td rowspan="5" valign="top" nowrap="nowrap"><img src="Dance-Mania-Party.jpg" alt="titre3" width="100" height="100" /></td>
<td width="35%" valign="top" nowrap="nowrap"><div align="left">
<label></label>
<form name="Raidoweb1">
<select name="playlist1" onchange="Choisir1()">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="1">Akon Lonely</option>
<option value="2">Bbp Candy Shop</option>
<option value="3">Breeze Vs Lost Witness Rise Again</option>
<option value="4">Caramell Caramelldansen</option>
<option value="5">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre1" size="32" value="" type="text" /></form>
</div></td>
<td width="35%" valign="top" nowrap="nowrap"><label></label></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Année sorti : (2008) </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><span property="dc:content">genre: Dance </span></td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Ttitre : Dance Mania Party</td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"> </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
</table>
A voir également:
- Aide code javascript
- Code ascii - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code activation windows 10 - Guide
- Code blocks - Télécharger - Langages
3 réponses
Voici l'idée générale
1 seul script Choisir3 appelé par les 3 select. Pour que cela fonctionne le plus simplement du monde tu généralises le format de tes formulaires ( f1 = f3 != f2 ) au niveau de tes indices ou tu récupère le texte de l'option
<html>
<head>
<script type="text/javascript" language="javascript">
function Choisir(){
var indice_selectionne=document.Raidoweb.playlist.selectedIndex;
var chango=document.Raidoweb.playlist.options[indice_selectionne].value;
switch (chango){
case "Choisir ton titre":document.Raidoweb.Titre.value="";break;
case "Akon Lonely":document.Raidoweb.Titre.value="Akon Lonely";break;
case "Bbp Candy Shop":document.Raidoweb.Titre.value="Bbp Candy Shop";break;
case "Breeze Vs Lost Witness Rise Again":document.Raidoweb.Titre.value="Breeze Vs Lost Witness Rise Again";break;
case "Caramell Caramelldansen":document.Raidoweb.Titre.value="Caramell Caramelldansen";break;
case "Coone And Ghost Pitch Up":document.Raidoweb.Titre.value="Coone And Ghost Pitch Upp";break;
}
}
function Choisir1(){
var indice_selectionne=document.Raidoweb1.playlist1.selectedIndex;
var chango=document.Raidoweb1.playlist1.options[indice_selectionne].value;
switch (chango){
case "Choisir ton titre":document.Raidoweb1.Titre1.value="";break;
case "1":document.Raidoweb1.Titre1.value="Akon Lonely";break;
case "2":document.Raidoweb1.Titre1.value="Bbp Candy Shop";break;
case "3":document.Raidoweb1.Titre1.value="Breeze Vs Lost Witness Rise Again";break;
case "4":document.Raidoweb1.Titre1.value="Caramell Caramelldansen";break;
case "5":document.Raidoweb1.Titre1.value="Coone And Ghost Pitch Upp";break;
}
}
function Choisir3(idForm, leSelect) {
var indice = leSelect.options[leSelect.selectedIndex].value;
var le_form = document.getElementById(idForm);
le_form.Titre.value = indice;
}
</script>
</head>
<body>
<table cellspacing="0" cellpadding="0">
<tr>
<td rowspan="5" valign="top" nowrap="nowrap"><img src="Dance-Mania-Party.jpg" alt="titre3" width="100" height="100" /></td>
<td width="35%" valign="top" nowrap="nowrap"><div align="left">
<label></label>
<form name="Raidoweb" id='f1'>
<select name="playlist" onchange="Choisir3('f1', this)">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="Akon Lonely">Akon Lonely</option>
<option value="Bbp Candy Shop">Bbp Candy Shop</option>
<option value="Breeze Vs Lost Witness Rise Again">Breeze Vs Lost Witness Rise Again</option>
<option value="Caramell Caramelldansen">Caramell Caramelldansen</option>
<option value="Coone And Ghost Pitch Up">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre" size="32" value="" type="text" /></form>
</div></td>
<td width="35%" valign="top" nowrap="nowrap"><label></label></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Année sorti : (2008) </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><span property="dc:content">genre: Dance </span></td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Titre : Dance Mania Party</td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"> </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
</table>
<br />
<br />
<table cellspacing="0" cellpadding="0">
<tr>
<td rowspan="5" valign="top" nowrap="nowrap"><img src="Dance-Mania-Party.jpg" alt="titre3" width="100" height="100" /></td>
<td width="35%" valign="top" nowrap="nowrap"><div align="left">
<label></label>
<form name="Raidoweb1" id='f2'>
<select name="playlist1" onchange="Choisir3('f2', this)">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="1">Akon Lonely</option>
<option value="2">Bbp Candy Shop</option>
<option value="3">Breeze Vs Lost Witness Rise Again</option>
<option value="4">Caramell Caramelldansen</option>
<option value="5">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre" size="32" value="" type="text" /></form>
</div></td>
<td width="35%" valign="top" nowrap="nowrap"><label></label></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Année sorti : (2008) </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><span property="dc:content">genre: Dance </span></td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Ttitre : Dance Mania Party</td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"> </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
</table>
<br>
<form name="Raidoweb" id='f3'>
<select name="playlist" onchange="Choisir3('f3', this)">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="Akon Lonely">Akon Lonely</option>
<option value="Bbp Candy Shop">Bbp Candy Shop</option>
<option value="Breeze Vs Lost Witness Rise Again">Breeze Vs Lost Witness Rise Again</option>
<option value="Caramell Caramelldansen">Caramell Caramelldansen</option>
<option value="Coone And Ghost Pitch Up">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre" size="32" value="" type="text" />
</form>
</body>
</html>
1 seul script Choisir3 appelé par les 3 select. Pour que cela fonctionne le plus simplement du monde tu généralises le format de tes formulaires ( f1 = f3 != f2 ) au niveau de tes indices ou tu récupère le texte de l'option
<html>
<head>
<script type="text/javascript" language="javascript">
function Choisir(){
var indice_selectionne=document.Raidoweb.playlist.selectedIndex;
var chango=document.Raidoweb.playlist.options[indice_selectionne].value;
switch (chango){
case "Choisir ton titre":document.Raidoweb.Titre.value="";break;
case "Akon Lonely":document.Raidoweb.Titre.value="Akon Lonely";break;
case "Bbp Candy Shop":document.Raidoweb.Titre.value="Bbp Candy Shop";break;
case "Breeze Vs Lost Witness Rise Again":document.Raidoweb.Titre.value="Breeze Vs Lost Witness Rise Again";break;
case "Caramell Caramelldansen":document.Raidoweb.Titre.value="Caramell Caramelldansen";break;
case "Coone And Ghost Pitch Up":document.Raidoweb.Titre.value="Coone And Ghost Pitch Upp";break;
}
}
function Choisir1(){
var indice_selectionne=document.Raidoweb1.playlist1.selectedIndex;
var chango=document.Raidoweb1.playlist1.options[indice_selectionne].value;
switch (chango){
case "Choisir ton titre":document.Raidoweb1.Titre1.value="";break;
case "1":document.Raidoweb1.Titre1.value="Akon Lonely";break;
case "2":document.Raidoweb1.Titre1.value="Bbp Candy Shop";break;
case "3":document.Raidoweb1.Titre1.value="Breeze Vs Lost Witness Rise Again";break;
case "4":document.Raidoweb1.Titre1.value="Caramell Caramelldansen";break;
case "5":document.Raidoweb1.Titre1.value="Coone And Ghost Pitch Upp";break;
}
}
function Choisir3(idForm, leSelect) {
var indice = leSelect.options[leSelect.selectedIndex].value;
var le_form = document.getElementById(idForm);
le_form.Titre.value = indice;
}
</script>
</head>
<body>
<table cellspacing="0" cellpadding="0">
<tr>
<td rowspan="5" valign="top" nowrap="nowrap"><img src="Dance-Mania-Party.jpg" alt="titre3" width="100" height="100" /></td>
<td width="35%" valign="top" nowrap="nowrap"><div align="left">
<label></label>
<form name="Raidoweb" id='f1'>
<select name="playlist" onchange="Choisir3('f1', this)">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="Akon Lonely">Akon Lonely</option>
<option value="Bbp Candy Shop">Bbp Candy Shop</option>
<option value="Breeze Vs Lost Witness Rise Again">Breeze Vs Lost Witness Rise Again</option>
<option value="Caramell Caramelldansen">Caramell Caramelldansen</option>
<option value="Coone And Ghost Pitch Up">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre" size="32" value="" type="text" /></form>
</div></td>
<td width="35%" valign="top" nowrap="nowrap"><label></label></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Année sorti : (2008) </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><span property="dc:content">genre: Dance </span></td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Titre : Dance Mania Party</td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"> </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
</table>
<br />
<br />
<table cellspacing="0" cellpadding="0">
<tr>
<td rowspan="5" valign="top" nowrap="nowrap"><img src="Dance-Mania-Party.jpg" alt="titre3" width="100" height="100" /></td>
<td width="35%" valign="top" nowrap="nowrap"><div align="left">
<label></label>
<form name="Raidoweb1" id='f2'>
<select name="playlist1" onchange="Choisir3('f2', this)">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="1">Akon Lonely</option>
<option value="2">Bbp Candy Shop</option>
<option value="3">Breeze Vs Lost Witness Rise Again</option>
<option value="4">Caramell Caramelldansen</option>
<option value="5">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre" size="32" value="" type="text" /></form>
</div></td>
<td width="35%" valign="top" nowrap="nowrap"><label></label></td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Année sorti : (2008) </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"><span property="dc:content">genre: Dance </span></td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap">Ttitre : Dance Mania Party</td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
<tr>
<td valign="top" nowrap="nowrap"> </td>
<td valign="top" nowrap="nowrap"> </td>
</tr>
</table>
<br>
<form name="Raidoweb" id='f3'>
<select name="playlist" onchange="Choisir3('f3', this)">
<option value="Choisir ton titre">Choisir ton titre</option>
<option value="Akon Lonely">Akon Lonely</option>
<option value="Bbp Candy Shop">Bbp Candy Shop</option>
<option value="Breeze Vs Lost Witness Rise Again">Breeze Vs Lost Witness Rise Again</option>
<option value="Caramell Caramelldansen">Caramell Caramelldansen</option>
<option value="Coone And Ghost Pitch Up">Coone And Ghost Pitch Up</option>
</select>
<input name="Titre" size="32" value="" type="text" />
</form>
</body>
</html>
Bonjour,
L'idée générale est de personnaliser ton script avec quelques parametres du genre id ou ojet select
ex
<SELECT NAME="num" ID="menu_select" CLASS="texte" onChange="MM_jumpMenu('parent',this)">
...
</select>
function MM_jumpMenu(targ,selObj) {
// selObj = <select>... </select>
eval(targ+".location='prod.php?num="+selObj.options[selObj.selectedIndex].value+"'");
}
L'idée générale est de personnaliser ton script avec quelques parametres du genre id ou ojet select
ex
<SELECT NAME="num" ID="menu_select" CLASS="texte" onChange="MM_jumpMenu('parent',this)">
...
</select>
function MM_jumpMenu(targ,selObj) {
// selObj = <select>... </select>
eval(targ+".location='prod.php?num="+selObj.options[selObj.selectedIndex].value+"'");
}
Bonjour,
merci de ta réponse mes le souci c que je début en java script et je comprend un peut ton code mes sur plusieurs image avec plusieurs image et plusieurs titre je voie pas bien comment faire :/.
exemple 1er paragraphe :
Image1 (ici le menu qui contiens tout les titres) ici la case qui va servir a copier le titre
(Titre1)
(Titre2) etc..
2eme paragraphe :
Image2 (ici le menu qui contiens tout les titres) ici la case qui va servir a copier le titre
(Titre1)
(Titre2) etc..
3eme paragraphe :
Image2 (ici le menu qui contiens tout les titres) ici la case qui va servir a copier le titre
(Titre1)
(Titre2) etc..
Cordialement Stéphane
merci de ta réponse mes le souci c que je début en java script et je comprend un peut ton code mes sur plusieurs image avec plusieurs image et plusieurs titre je voie pas bien comment faire :/.
exemple 1er paragraphe :
Image1 (ici le menu qui contiens tout les titres) ici la case qui va servir a copier le titre
(Titre1)
(Titre2) etc..
2eme paragraphe :
Image2 (ici le menu qui contiens tout les titres) ici la case qui va servir a copier le titre
(Titre1)
(Titre2) etc..
3eme paragraphe :
Image2 (ici le menu qui contiens tout les titres) ici la case qui va servir a copier le titre
(Titre1)
(Titre2) etc..
Cordialement Stéphane