Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

149
Vistas
Auto-submitting a form only on certain options

I want to create a form that would submit onchange but only on certain options. This is my code do far:

<form method="post" action="">
   <select name="period" id="period" class="form-control m-1" onchange='this.form.submit()'>
      <option value="" disabled hidden selected>default</option>
      <option value="1">option 1</option>
      <option value="2">option 2</option>
      <option value="3">option 3</option>
      <option value="4">option 4</option>
   </select>
</form>

On options 1-3 I want to have it sumbitted onchange or just whenever the option is chosen but for option 4 I want to create a modal in which the user would input his data and then it would submit. Is there any way to do that?

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

try out the following code

<form method="post" action="">
   <select name="period" id="period" class="form-control m-1" onchange='onChangeFun()'>
      <option value="" disabled hidden selected>default</option>
      <option value="1">option 1</option>
      <option value="2">option 2</option>
      <option value="3">option 3</option>
      <option value="4">option 4</option>
   </select>
</form>

javascript below

function onChangeFun() {
    selected_val = document.getElementById('period').value

    if (0 < selected_val < 4) {
        // form submit function
        // this.form.submit()
    }

    if ( selected_val == 4) {
        // perform action on selection of 4 th option
    }
}

if any doubt comment ill happy to help

about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda