显示基于第一个下拉列表的第二个下拉列表不起作用
Showing 2nd Dropdown based on First drop down not working
我是一名学习网络开发的新手。我正在尝试创建一个带有两个下拉菜单的简单表单。基于第一个下拉菜单,第二个下拉菜单应该是可见的。
但它不起作用:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<div class="container">
<div class="box">
<form>
<div class="ccms_form_element cfdiv_custom">
<div class="col-md-4">
<label for="inputType">Input Type</label></div>
<div class="col-md-8" style="font-size:16pt;">
<select id="inputType" required name="inputType" style="width:500px" onChange="ChangeDropdowns();">
<option value="">Select Type : Type Of You Want to Process</option>
<option value="text">Text </option>
<option value="genome">Numbers</option>
<option value="chacha">Special Characters</option>
</select>
</div>
</div>
</div>
<div class="style-sub-1" id="dataType" style="display: none;" >
<div class="col-md-4">
<label for="inputType">Data Type</label></div>
<div class="col-md-8" style="font-size:16pt;">
<select id="data" required name="data" style="width:500px">
<option value="">Select Data Source : Where is your Data?</option>
<option value="text">Data is already in Server</option>
<option value="genome">Need to Upload the File</option>
</select>
</div>
</div>
<div class="row">
<script>
function ChangeDropdowns() {
$(".style-sub-1").show();
}
</script>
</body>
</html>
谁能告诉我我做错了什么?
使用以下内容,使用 JQuery 检测第一个 select 中的变化 - 并包括 JQuery,如 Scott 所说
$( document ).ready(function() {
$("#inputType").on('change', function (){
$(".style-sub-1").show();
});
});
您似乎在尝试使用 jquery(javascript 代码中的 $)。
但是,您尚未在 html.
中指定 jquery 脚本
尝试添加这个
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.js"></script>
在头块之间
我是一名学习网络开发的新手。我正在尝试创建一个带有两个下拉菜单的简单表单。基于第一个下拉菜单,第二个下拉菜单应该是可见的。
但它不起作用:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<div class="container">
<div class="box">
<form>
<div class="ccms_form_element cfdiv_custom">
<div class="col-md-4">
<label for="inputType">Input Type</label></div>
<div class="col-md-8" style="font-size:16pt;">
<select id="inputType" required name="inputType" style="width:500px" onChange="ChangeDropdowns();">
<option value="">Select Type : Type Of You Want to Process</option>
<option value="text">Text </option>
<option value="genome">Numbers</option>
<option value="chacha">Special Characters</option>
</select>
</div>
</div>
</div>
<div class="style-sub-1" id="dataType" style="display: none;" >
<div class="col-md-4">
<label for="inputType">Data Type</label></div>
<div class="col-md-8" style="font-size:16pt;">
<select id="data" required name="data" style="width:500px">
<option value="">Select Data Source : Where is your Data?</option>
<option value="text">Data is already in Server</option>
<option value="genome">Need to Upload the File</option>
</select>
</div>
</div>
<div class="row">
<script>
function ChangeDropdowns() {
$(".style-sub-1").show();
}
</script>
</body>
</html>
谁能告诉我我做错了什么?
使用以下内容,使用 JQuery 检测第一个 select 中的变化 - 并包括 JQuery,如 Scott 所说
$( document ).ready(function() {
$("#inputType").on('change', function (){
$(".style-sub-1").show();
});
});
您似乎在尝试使用 jquery(javascript 代码中的 $)。 但是,您尚未在 html.
中指定 jquery 脚本尝试添加这个
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.js"></script>
在头块之间