M
MattB
I'm just trying to do some simple javascript in a form to convert Lbs in
one textbox to kg in another. I'm doing the following inside a If Not
IsPostBack block:
Dim strLbs2kg As String
strLbs2kg = "<script language='javascript'> " & _
"function Lbs2kg() " & _
"{" & _
"var Lbs = 0; " & _
"Lbs = " & txtWeight.ClientID & ".value; " & _
txtWeight_m.ClientID & ".value = Lbs*0.454; " & _
"}" & _
"</script>"
Page.RegisterClientScriptBlock("Lbs2kg", strLbs2kg)
txtWeight.Attributes.Add("onChange", "Lbs2kg()")
But when I type into my txtWeight box and tab off, the kg field is not
populated and I get an script error in the browser saying:
Error: 'txtWeight' is undefined
Code: 0
I thought the ClientID were automatically generated. Id that not true?
Any hints on making this work? Thanks!
Matt
one textbox to kg in another. I'm doing the following inside a If Not
IsPostBack block:
Dim strLbs2kg As String
strLbs2kg = "<script language='javascript'> " & _
"function Lbs2kg() " & _
"{" & _
"var Lbs = 0; " & _
"Lbs = " & txtWeight.ClientID & ".value; " & _
txtWeight_m.ClientID & ".value = Lbs*0.454; " & _
"}" & _
"</script>"
Page.RegisterClientScriptBlock("Lbs2kg", strLbs2kg)
txtWeight.Attributes.Add("onChange", "Lbs2kg()")
But when I type into my txtWeight box and tab off, the kg field is not
populated and I get an script error in the browser saying:
Error: 'txtWeight' is undefined
Code: 0
I thought the ClientID were automatically generated. Id that not true?
Any hints on making this work? Thanks!
Matt