0

I have a dropdown menu that allows the user to select between three different use cases, and I want to pass that information to the next page.

<option id='b2c-menu' value="Delivery">Delivery</option>
<option id='taxi-menu' value="Air Taxi">Taxi</option>
<option id='hub-menu' value="Hub-to-Hub">Metro</option>

On select, I'm capturing this option as a variable in my JavaScript, and I'd like my second page to be aware of what the currently selected option is. To pass that, I'd like to do something like this:

<a href="page2/{{ selected_option }}"</a>

Is there a way to make my links dynamic based on my JS content?

1 Answer 1

1

There's several ways to get there. One is to set the location.href dynamically on click. Something like this works well for me:

$('#mybutton').click(function(){
   window.location.href = "{% url '2ndlocation' %}?option=" + $('#myoption').val();
   return false;
});
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.