且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javascript用于启用和禁用其他下拉列表的选定值的下拉列表

更新时间:2023-02-05 08:19:00

对第一个DropDownList使用onchange事件。根据选择启用/禁用第二个DropDownList。



Use onchange event for first DropDownList. Enable/Disable second DropDownList based on the selection.

<script>
function EnableDisable()
{
var e = document.getElementById("FirstDropDownList");
var selectedText = e.options[e.selectedIndex].text;
if(selectedText == "Enable")
document.getElementById("SecondDropDownList").disabled=false;
else
document.getElementById("SecondDropDownList").disabled=true;
}
</script>


您好,



请尝试以下代码。

我使用过jquery,这适用于所有浏览器和任何版本的浏览器。你只需要在你的页面中包含jquery。

Hi,

Try the following code.
I have used jquery and this will work with all browser and any versions of browser. You just have to include the jquery in your page.


document )。ready( function ()
{

var dropDown1 =
(document).ready(function () { var dropDown1 =