Hi I am trying to disable a dropdownlist in an asp.net web application whenever the selected index is changed. I have the following javascript in my web app but whenever it gets to the disabled = true line it is falling over. What I want to know is that the correct way to disable a dropdownlist in javascript. The dropdown list is part of a usercontrol which is on the web form so I am not sure how to do this?

DateDrop is the name of the dropdownlist on the usercontrol.
Form1 is the name of the form

function SubmitOnChange(dateOnChange)
{
var temp = dateOnChange.options[dateOnChange.selectedIndex].value;
document.Form1.Hid2.value = temp;
document.Form1.DateDrop.disabled=true;
document.Form1.submit;
}

Well the code looks ok... and the attribute disabled exists in the DOM.

However, the next line is a form submit (assuming you are using VB script.. otherwise it being accessed as an attribute instead of a function). But my point is that this function call will submit the form and forward the user to a new page, or back to the current page. So there isn't any point manipulating the current page - it will get refreshed soon anyway.

I'm presuming your using .NET? ihatedotnet.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.