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

148
Views
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 answers
Answer question

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 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!