When I have text boxes with values, I call my JavaScript method on one of the textboxes 'onblur'. The function looks like this:
function CalculateExpectedProductPrice() {
alert("hi i called");
var originalPrice = document.getElementById('hdnSelectedProductPrice').value;
var numberOfLicenses = document.getElementById('txtNumberOfLicense').value;
var enteredAmount = document.getElementById('txtAmount').value;
alert(originalPrice);
alert(numberOfLicenses);
alert(enteredAmount);
}
I get an alert message saying "hi i called", but not further.
However, I am not getting the values of these controls for some reason.
*Updated:* Here is a snippet of my HTML code:
<asp:HiddenField ID="hdnSelectedProductPrice" runat="server" />
<asp:TextBox ID="txtAmount" runat="server" Width="250px"></asp:TextBox>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="txtNumberOfLicense" runat="server" Width="35px" ></asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="txtNumberOfLicense" EventName="" />
</Triggers>
</asp:UpdatePanel>
Will there be any impact on the master-content page? The script and HTML are both on the same content page. Additionally, all these controls are part of the second step of a wizard control. Could this be causing the issue?
Updated:
I suspect that the wizard control might be causing the problem. Upon inspecting the generated HTML using Firebug, I noticed that IDs are assigned dynamically to controls inside the wizard. For example, the txtAmount textbox within the wizard control gets a name like:
ctl00_ContentPlaceHolder1_Wizard1_txtAmount
I would prefer not to use these generated IDs. Is there a way to find and set values for controls inside a wizard control without relying on these dynamic IDs?