Javascript函数在jsp文件中不起作用
Javascript functions not working in an jsp file
我有一个jsp文件没有运行我的javascript函数。当它在html文件中时,它就工作了。以下是用于创建此文件的html和javascript。单击单选按钮时,javascript切换窗体各部分的可见性。
<script language="Javascript">
//How many Questions
function CTDefault(){
document.getElementById("CTDefault").style.visibility="visible";
document.getElementById("CTManual").style.visibility="hidden";
document.getElementById("CTFile").style.visibility="hidden";
}
//Manual
function CTManual(){
document.getElementById("CTDefault").style.visibility="hidden";
document.getElementById("CTManual").style.visibility="visible";
document.getElementById("CTFile").style.visibility="hidden";
}
//Load Data from Form
function CTFile(){
document.getElementById("CTDefault").style.visibility="hidden";
document.getElementById("CTManual").style.visibility="hidden";
document.getElementById("CTFile").style.visibility="visible";
}
</script>
<!--Buttons-->
<div id="enterDataToggle" class="btn-group" data-toggle="buttons" >
<!--Default-->
<label class="btn btn-default active" id="checkin-label">
<input type="radio" onClick="CTDefault()" checked> Default
</label>
<!--Input Data Manually-->
<label class="btn btn-default active" id="checkin-label">
<input type="radio" checked onClick="CTManual()">
Input Data Manually
</label>
<!--Load Data from File-->
<label class="btn btn-default active" id="checkin-label"
<input type="radio" value="checking" onClick="CTFile()">
Load Data from File
</label>
</div>
<!-- CT Input Data Default-->
<div style= "visibility:hidden; position:absolute" id="CTDefault">
<h4>Default-If you don't have this data, we have data for you. You do not have to do anything else. If you have data please click input data manually or load data from file.</h4>
</div>
<!--CT Manually-->
<div style=" position:absolute" id="CTManual">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Mean</th>
<th>Standard Deviation</th>
</tr>
</thead>
<tbody>
<tr>
<th>
<input name="CTMean" type="text" style="width:100%" required>
</th>
<th>
<input name="CTStd" type="text" style="width:100%" required>
</th>
</tr>
</tbody>
</table>
</div>
感谢您的帮助!:)
如果您在html标记之后声明您的脚本:
<!--Buttons-->
<div id="enterDataToggle" class="btn-group" data-toggle="buttons" >
<!--Default-->
<label class="btn btn-default active" id="checkin-label">
<input type="radio" name="option" onClick="CTDefault()" checked> Default
</label>
<!--Input Data Manually-->
<label class="btn btn-default active" id="checkin-label">
<input type="radio" name="option" checked onClick="CTManual()">
Input Data Manually
</label>
<!--Load Data from File-->
<label class="btn btn-default active" id="checkin-label">
<input type="radio" name="option" value="checking" onClick="CTFile()">
Load Data from File
</label>
</div>
<!-- CT Input Data Default-->
<div style= "visibility:hidden; position:absolute" id="CTDefault">
<h4>Default-If you don't have this data, we have data for you. You do not have to do anything else. If you have data please click input data manually or load data from file.</h4>
</div>
<!-- CT Input Data Default-->
<div style= "visibility:hidden; position:absolute" id="CTFile">
<h4>CTFile.</h4>
</div>
<!--CT Manually-->
<div style=" position:absolute" id="CTManual">
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Mean</th>
<th>Standard Deviation</th>
</tr>
</thead>
<tbody>
<tr>
<th>
<input name="CTMean" type="text" style="width:100%" required>
</th>
<th>
<input name="CTStd" type="text" style="width:100%" required>
</th>
</tr>
</tbody>
</table>
</div>
<script language="Javascript">
//How many Questions
function CTDefault(){
document.getElementById("CTDefault").style.visibility="visible";
document.getElementById("CTManual").style.visibility="hidden";
document.getElementById("CTFile").style.visibility="hidden";
}
//Manual
function CTManual(){
document.getElementById("CTDefault").style.visibility="hidden";
document.getElementById("CTManual").style.visibility="visible";
document.getElementById("CTFile").style.visibility="hidden";
}
//Load Data from Form
function CTFile(){
document.getElementById("CTDefault").style.visibility="hidden";
document.getElementById("CTManual").style.visibility="hidden";
document.getElementById("CTFile").style.visibility="visible";
}
</script>
你的灌篮者:https://plnkr.co/edit/m0f9XPdA4t85mYJpizl4?p=preview
PS:
- 一个标签标签未正确关闭
- 示例中不存在id为CTFile的元素
- 你应该用一个唯一的名字来命名你的单选按钮
相关文章:
- 带有凭据的角度文件上载(CORS)不起作用
- html文件中的script标记根本不起作用
- grunt上的压缩文件夹不起作用
- 当我在浏览器中打开HTML文件时,javascript不起作用
- AJAX上传文件不起作用
- 在Hapi.js中提供静态JavaScript文件不起作用
- ngResource没有'从JSON文件解析HTML时不起作用
- jQueryAjax调用在单独的.js文件中不起作用
- PhoneGap读写文件获胜'不起作用
- 我尝试使用我的本地js文件来获取远程IP数据,但它不起作用
- 某些js文件在Drupal中不起作用
- 使用gulp-angular gettext从JS文件中提取字符串不起作用
- google.setOnLoadCallback()在单独的JS文件中不起作用
- css&js文件在php中不起作用
- 从HTML链接时,Javascript文件不起作用
- 如果在include文件中使用连接,Jquery ajax调用将不起作用
- php文件中包含的jquery文件在服务器上不起作用
- Cufon-builder-font-js文件在Fabric.js中不起作用
- 如果.htaccess文件中只写了一行代码,那么我所有的css和js都不起作用,如何修复它
- Haskell调用Node.js文件不起作用