I have a Wizard Control that contains a number of controls:
After the user selects an item from a DropDown, and the control has lostfocus, I need the selected value to pre-populate a TextBox usingjavascript.
If I create a 'new website' and just throw a dropdown list and textbox onto the page the following code works perfectly:
** Default.aspx.vb:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
DropDownList1.Attributes.Add("onblur", "FillTextbox()")
End Sub
** Default.aspx:
function FillTextbox ()
{
document.getElementById("TextBox1").value=document.getElementById("DropDownList1").value;
}
The above code, however DOESN'T work if the controls are embedded in a wizard control.
Thus, my question is: How do I get the code to work if the DropDown and TextBox controls are in a Wizard Control?
Any help would be much appreciated!
I believe when the control is embedded within another control the actual name that ends up being used includes the parent-control's name, e.g. Parent_mycontrol. Take a look at the source (right click, View Source) when you run the page to find the actual name of the control. You can reference it by that name in your javascript, fillTextbox() function.
Good luck.
You need to find the correct ID for the TextBox control. As suggested by the fellow developer you need to use the View Source and find the correct ID for the TextBox control. Once, you find the correct ID simply use that Id in the javascript function.
Thank you both SO MUCH for your help! That worked like a charm!
0 comments:
Post a Comment