Redirect page through a select php

Asked

Viewed 302 times

0

I would like to know how to redirect a page through a select, given that I need the value of the same.

<select name="setor" id="setor">
  <option value="">Selecionar Setor</option>
  <option value="age">Agenciamento</option>
  <option value="exp">Exportação</option>
  <option value="imp">Importação</option>
  <option value="int">Internação</option>
  <option value="pro">Processos</option>
</select>
  • Will pass the value by POST or GET?

  • via post, @Márcioeric.

  • And why not use the traditional method? <form method="post" .....

1 answer

1


You can do it using Javascript.

Creates a function in the onChange passing as parameter the chosen value.

It will call the function and send to a page with due value as parameter.

function redirectPage(v) {
    document.location.href = 'pagina.php?param='+v;    
}
<select name="setor" id="setor" onChange="redirectPage(this.value)">
  <option value="">Selecionar Setor</option>
  <option value="age">Agenciamento</option>
  <option value="exp">Exportação</option>
  <option value="imp">Importação</option>
  <option value="int">Internação</option>
  <option value="pro">Processos</option>
</select>

  • How do I send the information via POST, @Diegosouza?!

  • Do an ajax inside that function.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.