JaCrews
asked on
Passing ClientID to Javascript from asp.net textbox
I have developed a site that uses both static ASP.net Textboxes and Dynamically created textboxes to hold dollar amounts. I have also created a javascript that allows the user to type in " 1+2+3..." and onBlur will add the totals together. Where i am running into an issue is I am not sure how to use the same function for all the textboxes. I understand that the client ID will tell the javascript where to look, but how to I pass that client ID from the asp.net side in the onBlur? I know I will have to pass an argument un the javascript function, but have had trouble figuring this out. Any help is appreciated.
Javascript:
function solve() {
with (Math) {
answer = eval(document.getElementBy Id("<%=txt Candy.Clie ntID%>").v alue);
document.getElementById("< %=txtCandy .ClientID% >").value = answer;
}
}
ASP textbox:
<td><asp:TextBox
Width = "90px"
ID="txtCandy"
runat="server"
ToolTip="Candy Total for the Day"
/>
</td>
Attributes added in the Page_load section:
txtCandy.Attributes.Add("o nBlur", "solve(this);return false;")
Javascript:
function solve() {
with (Math) {
answer = eval(document.getElementBy
document.getElementById("<
}
}
ASP textbox:
<td><asp:TextBox
Width = "90px"
ID="txtCandy"
runat="server"
ToolTip="Candy Total for the Day"
/>
</td>
Attributes added in the Page_load section:
txtCandy.Attributes.Add("o
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Heh, we've all done it. At least you got it working now. Cheers.
ASKER