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

137
Views
Seleccionar menú desplegable sin botón de enviar

Estoy creando una función de clasificación usando el menú desplegable de selección. No hay errores pero no funciona. ¿Hay alguna parte en la que lo estoy haciendo mal? Esto funciona bien cuando uso este método para filtros de casilla de verificación.

js

 <script type="text/javascript"> $(function () { $('select').on('change', function () { $('#filter-posts-form').submit(); }); }); </script>

php

 <form id="filter-posts-form" method="post" action="main.php"> <div class="table-filter-group"> <select name="filter-posts" id="filter-posts" class="filter-posts" > <option value=""<?=(isset($_POST['MostPopular'])? 'selected':'')?>>Most Popular</option> <option value=""<?=(isset($_POST['Latest'])? 'selected':'')?>>Latest</option> </select> </div> </form>
 if(isset($_POST['MostPopular'])){ //function }elseif(isset($_POST['Latest'])){ //function }
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Esto funcionará sin Ajax, copie el formulario y pegue

 <form id="filter-posts-form" method="post" action=""> <select name="filter-posts" id="filter-posts" class="filter-posts"> <option value="1" <?= (isset($_POST['filter-posts']) && $_POST['filter-posts'] == 1 ? 'selected' : '') ?>>Most Popular</option> <option value="2" <?= (isset($_POST['filter-posts']) && $_POST['filter-posts'] == 2 ? 'selected' : '') ?>>Latest</option> </select> </div> </form>

about 4 years ago · Juan Pablo Isaza Report

0

Sospecho que simplemente no cargó jQuery ya que los códigos se ven bien.

intenta agregar esto al principio.

 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></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!