How to set the value of a text box with javascript on an ASP.NET webform

asp.net, html, javascript

Solution

If I understand you correctly, you are just trying to set the value, just use:

document.getElementById("monthlyAmount").value = "test";

Problem

so in a form I have the following control: ``` <asp:TextBox runat="server" ID="monthlyAmount" ClientIDMode="Static"/> ``` The ClientIDMode Static is because a master page is in use. I then have this Button: ``` <input type="button" id="calculate" onclick="AutoFillEstimate()" value="Calculate Estimate" /> ``` Wired to this Script: ``` <script type="text/javascript"> function AutoFillEstimate() { document.getElementById("monthlyAmount").nodeValue = "test"; } </script> ``` I feel like I'm just using nodeValue instead of what I should be using, but I have no idea where to look for reference on these things.

Original source