jQuery event (志愿者活动) 项目中用到的JQUERY
/*** event: js* author: chengRenYin* emailTo: maomaoyu2099@163.com*//*** 查询活动*/function queryEvent() {//获取所有checkbox的值var ckVal = '';$('input[name="ckTime"]').each(function(){if($(this).attr('checked')){ckVal += $(this).val()+':';}});var eventTime = ckVal.substring(0,(ckVal.length-1));//给复选框时间赋值$('#eventTime').val(eventTime); //提交表单document.forms[0].submit(); } /*** 查看 当前的活动*/ function particular(eName,eType,eAddress,eTime,remark){//表单赋值$('#eventName').val(eName);$('#eventType').val(eType);$('#eventAddress').val(eAddress);$('#eventName').val(eName);$('#remark').val(remark);//表单时间赋值//alert('eTime = '+eTime);//赋值前清空复选框状态$('input[name="ckTime"]').each(function(){$(this).attr('checked','');});//赋当前 checkbox 状态值var ckTimeArray = eTime.split(':');$(ckTimeArray).each(function(){$('#'+this).attr('checked',true);});}/***表单重置*/function resetEvent(){document.forms[0].reset();}/*** 修改活动*/function amendSub(eId){//---------------表单验证----------------// 复选框验证var ck = ''; // 复选框状态$('input[name="ckTime"]').each(function(){if($(this).attr('checked')){ck += $(this).val();}});//获取所有checkbox的值var ckVal ='';$('input[name="ckTime"]').each(function(){if($(this).attr('checked')){ckVal += $(this).val()+':';}});var eventTime = ckVal.substring(0,(ckVal.length-1));//表单基本验证var eName = $('#eventName').val();var eAddress = $('#eventAddress').val();var eType = $('#eventType').val();if(eName==''){alert('活动名称没有填写!');return false;}if(eAddress==''){alert('活动地点没有填写!');return false;}if(eType=='0'){alert('活动类型没有选择!');return false;}if(ck==''){alert('选择时间 !');return false;}//ajaxvar data = 'eventId='+eId+'&eventType='+eType+'&eventAddress='+eAddress+'&eventTime='+eventTime+'&eventName='+eName;$.ajax({ type: "post", url: "saveModifyEvent.action", data: data, success: function(msg){ alert('保存成功!'); }, error:function() { alert('修改失败,联系管理员或稍后再试!'); }});}/***删除活动*/function deleteEvent(eId){if(window.confirm('确认删除?')){var data = 'eventId='+eId;$.ajax({ type: "post", url: "deleteEvent.action", data: data, success: function(msg){ alert('删除成功!'); window.location.reload(); }, error:function() { alert('删除失败,联系管理员或稍后再试!'); }});}}/*** 查询志愿者详细 信息*/function pUserInformation(pUserId){var data = 'userId='+pUserId;$.ajax({ type: "post", url: "queryLoginInfor.action", data: data, success: function(msg) { window.location.href = 'userInfor.jsp'; }, error:function() { alert('联系管理员或稍后再试!'); }});}/*** 控制 活动内容 字数 输入*/function checkLength(which) {var maxChars = 250;if (which.value.length > maxChars){which.value = which.value.substring(0,maxChars);}var curr = maxChars - which.value.length;document.getElementById("chLeft").innerHTML = curr.toString();}