I have a list of values. Within the list of values is a status which has a hyperlink to a particular model form.
I want to dynamically change the hyperlink based on the select value to direct the user to different forms based on the select value.
So, for example, when the Model value is pending, I want the hyperlink to go to the pending form. When the status is invoice sent and the use clicks the hyperlink I want the user to to go to the payment form.
The code is below
<table id="example1" class="table table-bordered table-striped" data-order='[[ 0, "desc" ]]' data-page-length='25'><button onClick="refreshPage()" class="btn btn-secondary float-right" title="Refresh"><i class="fa fa-sync"></i></button>
<thead>
<tr>
<th>Script No.</th>
<th>Entered on</th>
<th>Script Type</th>
<th>Patient</th>
<th>Address</th>
<th>Email</th>
<th>Contact No</th>
<th>Product</th>
<th>Form</th>
<th>Units</th>
<th>Dispensing Price</th>
<th>Status</th>
<th>Dispatch Date</th>
<th>Worksheet ID</th>
<th></th>
</tr>
</thead>
<tbody>
{% for script in scripts %}
<tr>
<td>{{script.pk}}</td>
<td>{{script.entered_on}}</td>
<td>{{script.get_script_type_display}}
<td>{{script.patient}}</td>
<td>{{script.patient.address}} {{script.patient.city}} {{script.patient.AU_states}} {{script.patient.postal_code}}</td>
<td>{{script.patient.email}}</td>
<td>{{script.patient.mobile_number}}</td>
<td>{{script.product}}</td>
<td>{{script.product.form.description}}</td>
<td>{{script.quantity}}</td>
<td>$ {{ script.dispensing_price }}</td>
{% if script.dispatch_date is not none %}
<td>{{script.get_script_status_display}}</td>
{% else %}
<td> <a class="edit" href="#" data-url="{% url "script:script_update_status" script.pk %}">{{script.get_script_status_display}}</a></td>
{% endif %}
{% if script.dispatch_date is none %}
<td>Not Sent</td>
{% else %}
<td>{{script.dispatch_date}}</td>
{% endif %}
{% if script.document_id is none %}
<td>Not Made</td>
{% else %}
<style></style>
<td>{{script.document_id}}</td>
{% endif %}
<td><small><a href = "{% url 'script:script_detail' script.pk %}">View</a> | <a href="{% url "script:script_update" script.pk %}">Edit</a> | <a href="{% url 'label:product_label' script.pk %}">Lab Label</a> | <a href="{% url 'label:dispense_label' script.pk %}">Dispense Label
</a> | <a href="{% url 'label:shipping_label' script.pk %}">Shipping Label</a> | <a href="{% url "label:receipt" script.pk %}" >Health Fund Receipt</a> | <a href="{% url "label:repeat" script.pk %}">Repeat</a><!--0 {% if script.patient.target_species == 'A' %}| <a href = "{% url 'communication:send_counselling_email' script.pk %} ">Counselling Email</a>{% endif %}--></td>
</tr>
{% endfor %}
</tbody>
</table>
<script>
document.querySelectorAll('#example1 a.edit').forEach(function(a) {
a.addEventListener('click', function(e) {
e.preventDefault();
const url = this.dataset.url;
window.open(url, "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=250");
});
});
</script>
</div>```
Thanks in advance for any help.
Kind Regards,
AC