0

Helo,

I've got a question.

I've got a selection box in HTML. Now what I want is, that when the selection changed, a website is called with the value.

For example:

<select>
  <option value="a">a</option>
  <option value="b">b</option>
  <option value="c">c</option>
  <option value="d">d</option>
</select> 

Now, when I choose c, then the URL change.php?option=a is called.

Thank you :-)

3

1 Answer 1

0

i think you need something like this

<select>
<option value="a">a</option>
<option value="b">b</option>
<option value="c">c</option>
<option value="d">d</option>
</select>

<script>
var select = document.querySelector('select');
select.addEventListener('change', function() {

var myURL = window.location.protocol + "//" + window.location.host + 
window.location.pathname;
document.location = myURL + "?option=" + select.value;

})
</script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.