javascript用于启用和禁用其他下拉列表的选定值的下拉列表 [英] javascript for enable and disable dropdownlist on selected value of other dropdownlist

查看:129
本文介绍了javascript用于启用和禁用其他下拉列表的选定值的下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在其他下拉列表的选定值上启用禁用下拉列表

i want to enable disable dropdownlist on selected value of other dropdownlist

推荐答案

对第一个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 =


这篇关于javascript用于启用和禁用其他下拉列表的选定值的下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆