|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
enable/disable text box based on dropdownlist via javascriptHi;
I think this is easy - but I haven't been able to figure out exactly what to do (my attempts have failed). When the value of a DropDownList changes, I want a javascript function to enable/disable a TextBox based on the new selected value from this list. How can I do this? In your code-behind, add a JavaScript event handler to the DropDownList
control to handle the change event and to do whatever you please: DropDownList1.Attributes.Add("onchange","document.forms[0].txtBox.value = '';"); HTH, Axel Dahmen ------------------ Show quoteHide quote "David Thielen" <thielen@nospam.nospam> schrieb im Newsbeitrag news:7471799A-4F35-4274-ADA6-43DAC656EC34@microsoft.com... > Hi; > > I think this is easy - but I haven't been able to figure out exactly what to > do (my attempts have failed). When the value of a DropDownList changes, I > want a javascript function to enable/disable a TextBox based on the new > selected value from this list. How can I do this? > > -- > thanks - dave > david_at_windward_dot_net > http://www.windwardreports.com > That's too easy <g>.
I'm still getting used to how to set this up as opposed to setting html events directly. Show quoteHide quote "Axel Dahmen" wrote: > In your code-behind, add a JavaScript event handler to the DropDownList > control to handle the change event and to do whatever you please: > > DropDownList1.Attributes.Add("onchange","document.forms[0].txtBox.value = > '';"); > > HTH, > Axel Dahmen > > > ------------------ > "David Thielen" <thielen@nospam.nospam> schrieb im Newsbeitrag > news:7471799A-4F35-4274-ADA6-43DAC656EC34@microsoft.com... > > Hi; > > > > I think this is easy - but I haven't been able to figure out exactly what > to > > do (my attempts have failed). When the value of a DropDownList changes, I > > want a javascript function to enable/disable a TextBox based on the new > > selected value from this list. How can I do this? > > > > -- > > thanks - dave > > david_at_windward_dot_net > > http://www.windwardreports.com > > > > > Hi dave,
To disable the TextBox using javascript, you can use window.document.getElementById("TextBox1").disabled=true; to achieve. Add a handler to the dropdownlist.onchange event, and set the desabled value according to the dropdownlist's value. HTH. Kevin Yu ======= "This posting is provided "AS IS" with no warranties, and confers no rights."
How to access control in FormView
Creating N rows of controls ObjectDataSource ... could not find a non-generic method ... that has parameters: ... How to add a dropdownlist to the column header in a GridView? post-back when the filename to upload changes Custom Web control question FormView/ItemTemplate - MultiView, Radio, & checkbox Exporting Datagrid to Excel Overriding Calendar.CreateChildControls PostBack and dynamically created controls |
|||||||||||||||||||||||