Reputation: 57
I have this JavaScript code how can i display the return value in a text box or in a label?
<script>
function getSelectedProjectID() {
var BalanceDue = @Model.BalanceDue;
return {
id: ProjectID
}
}
</script>
Upvotes: 0
Views: 154
Reputation: 381
you can assign your label an id
<label id="labelId"></label>
, and then just return function content to this label textConent:
document.getElementById("labelId").textContent = getSelectedProjectID();
Upvotes: 1
Reputation: 483
If you are using vanilla JS, you could do :
let labels = document.getElementsByTagName('label');
for (var i = 0; i < labels.length; i++) {
if (labels[i].htmlFor == 'currency') {
label.innerHTML = getSelectedProjectID().id;
}
}
Upvotes: 0