ASP.NET 1.x and 2.0 Application DesignApplication design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
i m designing registration form.i hav created a drop down box which contains list of different cities.now if the user does not find any particular city then i hav given choice for OTHER option..now problem comes when he selects OTHER option i want a new textbox to visible and can enter his uniqne city which is not in dropdown box.
So where do you find the problem, use the onchange event of dropdown and write a javascript function, here check the dropdown's selected value or text for Others, and display the textbox. You can write something like below:
sel: id of dropdown
txt: id of textbox
var obj = document.getElementById("sel");
if (obj.options[obj.selectedIndex].text == "Others")
{
document.getElementById("txt").style.visibility = "visible";
}
else
{
document.getElementById("txt").style.visibility = "hidden";
}
hi Mike thank u for the code......but i would not get onchange event of dropdown box, i m able to get in dropdown events like selectedindex change and ontextchange events....plz give more instructions......waiting for ur reply asap
Well, the onchange event will work for both server side and client side controls, although you may not find it in Intellisense, just write it, and check the result.
Warning 1 Validation (ASP.Net): Attribute 'Onchange' is not a valid attribute of element 'DropDownList'. E:\Demotestpage\Default.aspx 180 72 E:\Demotestpagehi mike i tried the code with onchange event but it gave the above warning and its not working