Direct to page with option already selected

0

I need when the user clicks a link it already directs to a page where it has a select. So far so good. The problem is to direct to this page and one of the options is already selected.

For example:

a {
  text-decoration: none;
  color: #000;
}
<a href="www.site.com.br/contato">
  <h5>Não achou o que procurava? Clique aqui!</h5>
</a>

I need you to go to the contact page and select the "Doubts" option.

<select class="text" id="assunto">
  <option>Selecione o assunto desejado</option>
  <option id="sugestoes" value="1">Fale conosco</option>
  <option id="duvidas" value="2">Dúvidas</option>
  <option id="trabalhe" value="3">Trabalhe conosco</option>
  <option id="clientes" value="4">Cadastro de Clientes</option>
  <option id="revendas" value="5">Cadastro de Revendas</option>
</select>
    
asked by anonymous 05.07.2018 / 15:12

1 answer

1

Simple enough, you put the selected attribute in the option you want to be selected.

<select class="text" id="assunto">
  <option>Selecione o assunto desejado</option>
  <option id="sugestoes" value="1">Fale conosco</option>
  <option id="duvidas" value="2" selected>Dúvidas</option>
  <option id="trabalhe" value="3">Trabalhe conosco</option>
  <option id="clientes" value="4">Cadastro de Clientes</option>
  <option id="revendas" value="5">Cadastro de Revendas</option>
</select>
    
05.07.2018 / 15:21