I am just getting a value from an input tag by javascript. But Now I need to pass this value to the Django template on the same page to do my required task.
<!DOCTYPE HTML>
 <HTML>
   <body>
    <h1>In Django Template</h1>
    <input type="text" id="agency_id" name="fname" value="1">
    <select class="select" name="delivery_agent" id="DeliveryAgent">
    <option class="form-control" value="{{ agent.id }}" {% if agent.id == delivery_agency_id  %} selected="selected" {% endif %}>{{ agent.name }}
  </option> {% endfor %}
</select>
<script>
  var delivery_agency_id = document.getElementById("agency_id").value;
  alert(delivery_agency_id )
</script>
Here, I am getting the agency_id by script. Now I need to pass it to the if condition as above code. Please help me to solve it.
 
    