javascript: checked 不可全选
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>jQuery checkbox 如何判断已经全选</title>
<link type="text/css" href="Public_File/geovindu.css" rel="stylesheet" media="all"/>
<link type="text/css" href="Public_File/print.css" media="print" rel="stylesheet"/>
<script src="Scripts/jquery.min.js" type="text/javascript"></script>
<script src="Scripts/ui.datepicker.js" type="text/javascript"></script>
<link rel="stylesheet" href="Scripts/ui.datepicker.css" type="text/css" media="screen" id="datepickerStyle" />
<script type="text/javascript">
function CheckedAll(){
//$(':checkbox').attr('checked','checked');
var isnull=true;
var allBox = $(":checkbox");
var ch1=$("#H1").attr("checked") ;
var ch2=$("#H2").attr("checked") ;
var ch3=$("#H3").attr("checked") ;
var tal=0;
if(ch1==true)
{
var str=$("#H1").val();
tal=tal+Number(str);
window.alert(str);
}
if(ch2==true)
{ var str1=$("#H2").val();
tal=tal+Number(str1);
window.alert(str1);
}
if(ch3==true)
{
var str2=$("#H3").val();
window.alert(str2);
tal=tal+Number(str2); }
window.alert('tal:'+tal);
//return;
if(tal==6)
{
isnull=false;
$("#H1").attr("checked",false);
$("#H2").attr("checked",false);
$("#H3").attr("checked",false);
// $("#Submit").load("ajax/test.html");
window.alert("不可以全選,請重新選擇!");
window.history.back();
window.location.reload(true); }
if(tal==0)
{
window.alert("未有選擇,請重新選擇!");
window.history.back();
window.location.reload(true); } } /*隻可以選擇一項類型門票
$(function () {
var allBox = $(":checkbox");
allBox.click(function () {
allBox.removeAttr("checked");
$(this).attr("checked", "checked");
});
$(":button").click(function () {
alert($(":checkbox:checked").val());
});
});
*/ function showp1()
{
document.all.P1.style.display='';
document.all.P2.style.display='';
//document.all.P3.style.display='none';
//document.all.showzi.style.display='none';
showzi.innerHTML="VIP黑咭號碼 (如適用)";
document.all.P4.style.display='none';
}
function showp2()
{
//document.all.P3.style.display='';
showzi.innerHTML="VIP咭號碼";
document.all.P4.style.display='';
document.all.P1.style.display='none';
document.all.P2.style.display='none';
} </script> </head> <body>
<form name="form1" method="post" action="SaveReQuestTickets18.asp?Action=Add&ProjectID=18">
<input name="H1" type="checkbox" id="H1" value="1" />
HK$480
<input name="Num1" type="text" id="Num1" value="2" size="10" readonly="readonly" style="background-color:#cccccc; color:red;"/>
張<span style="display:block;"><font color="#FF0000">(剩餘10張)</font></span> <input name="H2" type="checkbox" id="H2" value="2" />
HK$680
<input name="Num2" type="text" id="Num2" value="2" size="10" readonly="readonly" style="background-color:#cccccc; color:red;"/>
張<span style="display:block;"><font color="#FF0000">(剩餘10張)</font></span> <input name="H3" type="checkbox" id="H3" value="3" />
HK$880
<input name="Num3" type="text" id="Num3" value="2" size="10" readonly="readonly" style="background-color:#cccccc; color:red;"/>
張<span style="display:block;"><font color="#FF0000">(剩餘10張)</font></span>
<input type="submit" name="Submit" id="Submit" value="提交申請" class="bottonan" style="width:120px;height:35px" onclick="javascript:CheckedAll();"/>
<input type="reset" name="Submit2" value="重新填寫" class="bottonan" style="width:120px;height:35px" />
<input type="button" name="Submit3" value="返回門票列表" onClick="Javascript:location.href='LukFookTickets_Branch.asp?ProjectID=18';" class="bottonan" style="width:120px;height:35px"/>
<input type="hidden" name="Action" value="Add"/> <input type="hidden" name="EditId" value=""/>
</form>
</body> </html>
javascript: checked 不可全选的更多相关文章
- JavaScript基础6——全选示例
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- JavaScript Web API 全选反选案例
全选反选 全选和反选功能,在开发中可以说是应用得非常多的,以下通过案例分解,学习如何使用JS实现全选反选功能. 该功能可分为如下三大步骤: 1.全选 1.1 获取父checkbox,注册点击事件 1. ...
- JavaScript实现单击全选 ,再次点击取消全选
以下为实现思路,已测试,供参考 var allSet = document.getElementById('allSet');//获取全选按钮元素 var a = allSe ...
- html javascript checkbox实现全选功能
html代码 <input type="checkbox" id="all" />all</input> <input type= ...
- JavaScript CheckBox实现全选和部分选择
<html> <head> <script> function BatchAddToBasket() { var questionNums = ''; var ch ...
- jQuery/javascript实现全选全不选
<html> <head> <meta charset="utf-8"> <title>Checkbox的练习</title& ...
- 用javascript实现全选/反选组件
以下是本人制作的全选/反选 组件,供广大同行参考.指正: 效果如图: 在实现的过程中,全选和全部取消选中这两个功能较为简单,只需用for循环遍历所有复选框为true或false即可.反选也较为简单,也 ...
- JavaScript案例四:全选练习
JavaScript实现全选,全不选等效果... <!DOCTYPE html> <html> <head> <title>JavaScript全选练习 ...
- JavaScript 全选函数的实现
Html代码: <table id="purchase-info" class="table table-bordered table-hover table-st ...
随机推荐
- 从文本中读取字符——feof函数问题
feof()函数 函数原型:int feof(FILE *fp): 函数功能:检测流上的文件结束符,如果文件结束,则返回非0值,否则返回0,文件结束符只能被clearerr()函数清除 (函数feof ...
- grid布局学习二之子元素(项目)
/* grid-column-start属性:左边框所在的垂直网格线 grid-column-end属性:右边框所在的垂直网格线 grid-row-start属性:上边框所在的水平网格线 grid-r ...
- SpringBoot swagger-ui.html 配置类继承 WebMvcConfigurationSupport 类后 请求404
1 .SpringBoot启动类加上 注解 @EnableWebMvc @SpringBootApplication@EnableWebMvc public class Application { ...
- 【Spark工作原理】Spark任务调度理解
Spark内部有若干术语(Executor.Job.Stage.Task.Driver.DAG等),需要理解并搞清其内部关系,因为这是性能调优的基石. 节点类型有: 1. Master 节点: 常 ...
- HoloLens开发手记 - 使用Visual Studio Using Visual Studio
不论你是否使用DirectX或Unity来开发全息应用,你都会使用Visual Studio 2015来进行调试和部署应用.在本部分,你将会学习以下内容: 如何通过Visual Studio将你的应用 ...
- spring boot 集成 thymeleaf
例如meta标签,低版本标签必须要闭合,高版本不用这么严格. pom文件引入高版本jar包如下,propertis里添加:
- C# DataGridView下DataGridViewComboBoxColumn二级联动
效果: 代码: using System; using System.Collections.Generic; using System.ComponentModel; using System.Da ...
- 死磕 java集合之ArrayDeque源码分析
问题 (1)什么是双端队列? (2)ArrayDeque是怎么实现双端队列的? (3)ArrayDeque是线程安全的吗? (4)ArrayDeque是有界的吗? 简介 双端队列是一种特殊的队列,它的 ...
- Dapper内部分享ppt
http://www.knowsky.com/887446.htmlhttp://www.tritac.com/bp-24-dapper-net-by-examplehttp://www.cnblog ...
- 【转】使用notepad运行python
Notepad++是一个开源的文本编辑器,功能强大而且使用方便,一般情况下,Notepad++作为代码查看器,很方便,但是每次要运行的时候,总是需要用右键打开其他的IDE来编译和运行,总有些不方便.特 ...