开发者

Javascript - Disable a control when a drop down list selected index changed

I need to know how to disable a button when the selected index of a drop down list has changed. I want to do it in ja开发者_如何学运维vascript because i don't want to cause a postback.

Thanks.


Add this JavaScript function (it assumes your button has a my-button id):

function disableButton()
{
  button = document.getElementById("my-button");
  button.disabled = true;
}

In order to respond of the change of the selected index, add this onchange event to the dropdown: onchange="disableButton()"

Edit: For more information about the disabled property go to w3schools, they have lots of information about JavaScript and the HTML DOM.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜