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.
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.
Share Improve this question asked Mar 15, 2013 at 19:23 FirosoFiroso 6,68510 gold badges50 silver badges93 bronze badges2 Answers
Reset to default 13If I understand you correctly, you are just trying to set the value, just use:
document.getElementById("monthlyAmount").value = "test";
The correct way to do this is:
document.getElementById("<%= monthlyAmount.ClientID %>").value = "test";