Suppose I have dropdown field in PAGE A. Now on select event I want to redirect to PAGE B with some django context variables. The value of these context variable depends on the selected value of PAGE A dropdown field. How can I implement this in django?
I think the best solution here is passing params in the query string to the view.
<div id="selector">
<select>
<option value="{% url pageB param1 %}">Option 1</option>
<option value="{% url pageB param2 %}">Option 2</option>
<option value="{% url pageB param3 %}">Option 3</option>
</select>
</div>
<script>
$(function(){
// bind change event to select
$('#selector select').bind('change', function () {
var url = $(this).val(); // get selected value
if (url) { // require a URL
window.location = url; // redirect
}
return false;
});
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With