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

121
Views
reescritura de código en jquery basado en la selección seleccionada

funciona al 99%, donde no se puede agregar el atributo de requerido al campo de entrada. cuando una determinada condición coincide y también debería ejecutarse al cargar la página, incluso si el valor de selección no cambia.

y si se cambia el valor de select, entonces también debería ejecutarse.

Aquí está mi intento de código Javascript

 var e = document.getElementById("StatusID"); var strUser = e.options[e.selectedIndex].value; var _cost = document.getElementById('_total'); if(_cost.value == 0) { $(".Star").css('display','inline-block'); _cost.setAttribute("required", ""); } else { $(".Star").css('display','none'); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Actualizado:

Debe agregar un evento de cambio para StatusID :

 var e = document.getElementById("StatusID"); e.onchange = function() { changeHandler(); }; window.onload = function() { changeHandler(); }; function changeHandler() { var _cost = document.getElementById('_total'); var e = document.getElementById("StatusID"); var strUser = e.options[e.selectedIndex].value; if(_cost.value == 0) { $(".Star").css('display','inline-block'); _cost.setAttribute("required", ""); } else { $(".Star").css('display','none'); } }

En lo anterior (y en esta actualización), no necesita ingresar el código antes de cerrar la etiqueta del cuerpo.

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!