Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
No se puede elegir otra opción en Seleccionar etiquetas. Siempre por defecto es la primera opción con un valor

Hay preguntas similares como esta, pero no puedo encontrar lo que estoy buscando o me estoy perdiendo algo. Aquí está el código a continuación.

 <select id="colorSelector" onchange="getColor()"> <option>Choose a color</option> <option value="green">Green</option> <option value="red">Red</option> </select>

JS

 function getColor(){ if(document.getElementById('colorSelector').value = "green"){ document.getElementById('mainButton').setAttribute('onclick', 'colorChangeGreen()') }else if(document.getElementById('colorSelector').value = "red"){ document.getElementById('mainButton').setAttribute('onclick', 'colorChangeRed()') }}

Después de abrir el menú desplegable y elegir cualquiera de los dos colores, siempre elige verde y luego no puedo elegir rojo. Me pregunto qué necesito editar para poder elegir otros colores, quería poner algunas opciones más. Gracias.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

 <select id="colorSelector" onchange="getColor()"> <option>Choose a color</option> <option value="green">Green</option> <option value="red">Red</option> </select> <input type="button" id="mainButton" value="color" /> <script> function getColor(){ if(document.getElementById('colorSelector').value == "green"){ document.getElementById('mainButton').setAttribute('onclick', 'colorChangeGreen()') }else if(document.getElementById('colorSelector').value == "red"){ document.getElementById('mainButton').setAttribute('onclick', 'colorChangeRed()') }} </script>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!