0

I want to add an event to the specified tag <select> and when I choose one <option> saves its value and when I press the button moves to the page for that option.

<select id="subjselect" name="subj" onchange="location=this.options[this.selectedIndex].value;">
  <option value="www.facebook.com">option1</option>
  <option value="www.google.com">option2</option>
</select>
<input type="button" onClick="location=document.jump.menu.options[document.jump.menu.selectedIndex].value;" value="GO">
georg
  • 211,518
  • 52
  • 313
  • 390
  • `this.options[this.selectedIndex].value` can be `this.value`. But rather than setting a global variable that just reflects the value, why not dispense with change listener and just use the button: `location = document.getElementById('subjselect').value`. – RobG Oct 13 '19 at 13:14
  • does this help: https://stackoverflow.com/questions/7562095/redirect-on-select-option-in-select-box ? – georg Oct 13 '19 at 13:18

0 Answers0