'How to pass multiple parameters using Javascript
In project I want to pass variables such as id and model_type from template to view through an onclick function like:
<div class="menu-item px-3">
<a onclick="confirmalertApprove({{assets.id}}, {{assets.modal_type}})" class="menu-link px-3">Approve</a>
</div>
and
<script type="application/javascript">
function confirmalertApprove(id, model) {
var assets_id = id;
var modal_type= model;
.........
window.location.href = "{% url 'pending_assets_approval_view' 0, 1 %}".replace('0', assets_id).replace('1', modal_type);
..........
)
}
})
}
the above methode produce an error like:
I am a beginer in javascript. I do not know how to eliminate the error, is there any other way to transfer values instead
" window.location.href = "{% url 'pending_assets_approval_view' 0, 1 %}".replace('0', assets_id).replace('1', modal_type);"
please give me a help to overcome this problem.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|