0

I have a select box and have only one option in it (for now). What is want to achieve is that when a user selects that option, its value should be appended to a URL and the redirect to that URL below is the code I am trying.

  function firstbox()
  {
    var f_box_value = document.getElementById('first-box');
    window.location.href = "https://theultimatesleeptherapy.a.wpstage.net/checkout/?add-to-cart="+f_box_value;
  }
      <div class="offer-boxx">
    <h3 class="text-center">1 BOTTLE</h3>
    <div class="text-center">
      <img src="http://159.65.108.187/wp-content/uploads/image1.png" width="100%">
    </div>
    <table class="price-details" width="100%">
      <tr>
        <td><del>$34.99</del></td>
        <td><h1>$28</h1></td>
        <td><span>+ $4.99 S&H</span></td>
      </tr>
    </table>
    <div class="offer-details">
      <h5>Flavor:</h5>
      <select id="first-box" name="first-box">
        <option value="12345">Rainbow Freeze</option>
      </select>
    </div>
    <div class="action-btn">

     <button onclick="firstbox()" type="button">BUY NOW</button>
    </div>
  </div>

It is redirecting but not giving the required result, Instead of showing the value of the variable, it shows something like this at the end of the url [object%20HTMLSelectElement]

0 Answers0