Beginner problem :( | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Beginner problem :(

HI!!! I only started programming a week ago and I do not understand the error in my code. Could someone explain to me? --------------------------------------------------------------------------------------------------------- <!DOCTYPE html> <html> <head> <meta charset="UTF-8"/> <title>Diccionario de los días de la semana</title> </head> <body> <label for>Selecciona el día de la semana a traducir</label><br><br> <select name="dia" onchange="dias(this.value);"><br><br> <option value=""></option> <option value="1">Lunes</option> <option value="2">Martes</option> <option value="3">Miercoles</option> <option value="4">Jueves</option> <option value="5">Viernes</option> <option value="6">Sabado</option> <option value="7">Domingo</option> </select><br><br> <label>Traduccion</label><br><br> <span id="traduccion"></span> <script> function días(valor){ if(valor==1){ document.getElementById('dias').innerHTML="Monday"; } if(valor==2){ document.getElementById('dias').innerHTML="Thuesday"; } if(valor==3){ document.getElementById('dias').innerHTML="Wednesday"; } if(valor==4){ document.getElementById('dias').innerHTML="Thursday"; } if(valor==5){ document.getElementById('dias').innerHTML="Friday"; } if(valor==6){ document.getElementById('dias').innerHTML="Saturday"; } if(valor==7){ document.getElementById('dias').innerHTML="Sunday"; } } </script> </body> </html>

7th Dec 2018, 10:51 PM
Facundo Puebla
Facundo Puebla - avatar
4 Réponses
+ 4
Can you tell us the error that you received ? Whatever, I think the problem is from the name of your function. Replace días by dias, javascript doesn't like accent
7th Dec 2018, 10:55 PM
Chalza
Chalza - avatar
+ 2
Or also because there is no element_id after for, in <label for> tag
7th Dec 2018, 11:04 PM
Chalza
Chalza - avatar
+ 1
I replaced the accent, but it still does not work I think I would have to show the translation of the day of the week.
7th Dec 2018, 11:01 PM
Facundo Puebla
Facundo Puebla - avatar
+ 1
Thanks for the help, I have solved it. I had confused the ID: if(valor==1){ document.getElementById('traduccion').innerHTML="Monday";
7th Dec 2018, 11:18 PM
Facundo Puebla
Facundo Puebla - avatar