Click here to Skip to main content
15,899,314 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a drop down in my aspx page

I want to trigger an event on it so that if its selected index is 0 then it shows a textbox

I want to do this through JavaScript

C#
function do_Post(){
if(document.form1.dropdown.value!=0)
{
document.form1.submit();
}
}



How can i do this in aspx using JS??

what should i use instead of document.form1.dropdown? document.getElementbyID?? and how can i call it on aspx file??
Posted

This article by Chris has a very simple and clear answer on how to do this.

Using JavaScript to handle drop-down list selections[^]
 
Share this answer
 
Comments
Abhinav S 21-Jun-11 10:03am    
Yup. My 5.
Monjurul Habib 21-Jun-11 16:39pm    
nice link , my 5.
 
Share this answer
 
Comments
Syed Salman Raza Zaidi 21-Jun-11 15:25pm    
But i am using Server Control DropDownList
That's Aragon 27-Jun-11 2:48am    
You can use the same code for server control also. Only difference is that you have to find it by ClientID. i.e. document.getElementById('<%= YourddlId.ClientID%>')

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900