I have a ajax script which takes a field from my django form and retrieves a price field - Working Fine
I have a paypal form which I need to update the "amount" value with this retrieved value price. But when I pass it in it is returning as an object.
Would really appreciate any help or better way to accomplish this.
HTML:
<h1>Pay using PayPal</h1><form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="amount" value="0" id="id_amount">
</form>
<script>
$("#id_membership_title").change(function () {
var url = $("#regForm").attr("data-member-url");
var membership_title = $(this).val();
$.ajax({
url: url,
data: {
'membership_title': membership_title
},
success: function (data) {
$("#id_amount").html(data);
$("#id_price").html(data);
}
});
price = document.getElementById("id_amount");
price.setAttribute("value", $("id_amount"));
});
View To Retrieve Price:
def ajax_load_price(request):
membership = request.GET.get('membership_title')
mem_id = ClubMemberships.objects.filter(pk=membership)
return render(request, 'load_price_value.html', {'mem_id': mem_id})
HTML to render price:
{% for id in mem_id %}
{{ id.price }}
{% endfor %}