Target page with option already selected

Asked

Viewed 53 times

0

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

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 direct to the contact page now and select the option "Questions".

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

1 answer

1


Simple enough, you put the attribute Selected option you want to select.

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

  • But if now the customer wants to pass a link to make the resale registration?

  • Sorry Lucas, I didn’t understand the question. Pass a link where?

  • 1

    If the customer wants to pass a link to the Resell Registration option. They cannot use the same link because the Doubts option will be selected. But based on your answer I will do it in another format. Do an if in php and each time the url has the id of the option it will set the select.

Browser other questions tagged

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