0

I'm working with the Bootstrap drop down and I've got everything working except the final thing I need it to do. The user will select 1 of 3 options and then click 'Go!'. After clicking go it will check what the user chose and then redirect them to the correct page.

Here's what I had in JavaScript.

function gotopg() {

  var s = document.getElementById('selection');
  var selection = s.options[s.selectedIndex].value;

  if (selection == 1) {
    window.location.href = 'OptionOne.html';
  }
  else if (selection == 2) {
    window.location.href = 'OptionTwo.html';
  }
  else if (selection == 3) {
    window.location.href = 'OptionThree.html';
  }
}

And here's the HTML

<div>
  <select class="selectpicker" title='Choose your form...' id="selection" onChange="changed()" autofocus>
    <option style="text-align: left;">OptionOne</option>
    <option style="text-align: left;">OptionTwo</option>
    <option style="text-align: left;">OptionThree</option>
  </select>
  <script type="text/javascript">
    $(document).ready(function(e) {
      $('.selectpicker').selectpicker();
    });
  </script>
</div>

<br>
<br>
<button id="go" onClick="gotopg()" disabled="disabled" style="font-size: 20px;">Go!</button>

This was working just fine before I added in the Bootstrap Drop Down, now nothing is happening when clicking Go!. What do I have to do to get this working with the Bootstrap Drop Down?

yarl
  • 3,107
  • 1
  • 22
  • 28
Ryan Fitzgerald
  • 425
  • 4
  • 9
  • 20

0 Answers0