-1

As I create a select menu, which is in the first position with the current URL, changing the selected of option:

<select >
  <option value="http://www.test.com/teste1" selected>test1</option>
  <option value="http://www.test.com/teste2">Google</option>
  <option value="http://www.test.com/teste3">YouTube</option>
  <option value="http://www.test.com/teste4">test 4</option>
</select>

Example browser URL http://www.test.test.4:

<select >
  <option value="http://www.test.com/teste4" selected>test 4</option>
  <option value="http://www.test.com/teste1/">test1</option>
  <option value="http://www.test.com/teste2">Google</option>
  <option value="http://www.test.com/teste3">YouTube</option>
</select>
techraf
  • 64,883
  • 27
  • 193
  • 198
  • Welcome to Stack Overflow! Your question is very unclear as it stands. Please make a better attempt at explaining what you need. Do you need the `option` whose `value` attribute has the URL of the current page to always be selected by default? I've removed tags that are not relevant to the question. – Harry Oct 17 '16 at 06:58
  • The "selected" must be selected in the option with the url corrent. – valdir silva Oct 17 '16 at 19:57

1 Answers1

0

I'm not sure to understand, you include this code on all of this pages and you want to change selected option ?

Maybe you can do it with JS with the onload event on your body (on each pages).

Example for the http://www.test.com/teste2 body:

How do I programmatically set the value of a select box element using javascript?

<body onload="selectElement('http://www.test.com/teste2')">
Community
  • 1
  • 1