0

I have seen various post allowing user to do this by including the var as part of the url something like this http://127.0.0.1:8000/?var1="var1"+var2="var2"

But in my case I need to send the variable into href tag which goes to views function in my django app <a href="{% url 'process-payment'> I have the variable set like this:

<td><strong>Rs.<span id="totalPrice">{{ order.get_cart_total}}</span></strong></td>
.
.
<a href="{% url 'process-payment'> 
.
<script>
    var totalPrice = document.getElementById("totalPrice").innerHTML;   //picking a value through innerHTML
</script> 

Can anyone help me build this url so the value goes to views function

urls.py

urlpatterns=[
path('payment/',views.process_payment, name='process-payment'),
]
3
  • Does this help? stackoverflow.com/questions/17832194/… Commented May 21, 2020 at 8:42
  • No it didn't work for me, need some better solution. Even in the page the solution provided is not satisfying to others. Commented May 21, 2020 at 9:12
  • Did you close the <a> tag? It seems like you left it open, it should be: <a href="{% url 'process-payment' %}"></a> Commented Oct 16, 2020 at 21:19

0

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.