Javascript selects variants but correct variant not added to cart

Site is for a rental type of business.

I created a functioning javascript that allows me to take a zip code, a delivery date, and a pickup date. And with these values it chooses a combination of 3 variants. 1) Short-term vs long term (calculated by how many days 2) Delivery zone based on zip code, and 3) Delivery day of week.

After entering the values the user clicks a “calculate” button which will trigger the selection of the variant options.

The problem is, that though it displays the right variants selected, after clicking ‘add to cart’, the correct item does not get added to the cart — instead just the default selected item. How can I trigger a change event, so the entire page reflects the new variants (including updating the price) as well as making the add to cart button work correctly. (If i manually select one of the variants it works correctly).

Theme: Dawn

Pardon any sloppiness in this code, I’m only getting started with javascript :slight_smile:


  
  
  
  
  

 
      

  

               
              

 

  
               
              

  

  

  
  

    

  

  
      
  

| Rental Term:  |  <br><br> |
| - | - |
| Delivery Premium:  |  <br><br> |