user7983964
user7983964

Reputation: 57

How can i display JavaScript function return in textbox?

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

Answers (2)

Sanchez Panza
Sanchez Panza

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

P.B.UDAY
P.B.UDAY

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

Related Questions