用jquery实现隐藏列表表单的显示关闭切换以及Ajax方式改动提交相应的那一行的改动内容。
请勿盗版,转载请加上出处http://blog.csdn.net/yanlintao1
请勿盗版,转载请加上出处http://blog.csdn.net/yanlintao1
先给大家看看图片效果,大家不要直接复制代码,这样是执行不了的,由于你们数据库和我的不一样,可是你们能够自己读读这个代码。找找对自己实用的,当然我的方法也不是最好的希望大家能够给点意见。感激不尽。
(1)点击改动图标
(2)填写改动内容
(3)点击确定改动
jquery与css代码:
<style type="text/css">
.open{
display:block;
}
.close{
display:none;
}
</style>
<script language="javascript">
$(function(){ //监听改动,实现显示关闭之间的切换
$("tr").delegate("td[id='modify']","click",function(){
var id = $(this).attr('name');
$("#"+id).toggleClass("close");
}); //监听改动的确认改动button,并以ajax方式提交
$("td").delegate("input[name='update[]']","click",function(){
var id=$(this).parent().parent().attr('name');
var student_id1=$("input[name='student_id1']").map(function(){return $(this).val()}).get();
var date1=$("input[name='date1']").map(function(){return $(this).val()}).get();
var beforeclass_id1=$("input[name='beforeclass_id1']").map(function(){return $(this).val()}).get();
var class_id1=$("input[name='class_id1']").map(function(){return $(this).val()}).get();
var type1=$("select[name='type1']").map(function(){return $(this).val()}).get();
var remark1=$("input[name='remark1']").map(function(){return $(this).val()}).get();
$.post("/qtsc/update" ,{student_id1:student_id1[id],date1:date1[id],beforeclass_id1:beforeclass_id1[id],class_id1:class_id1[id],type1:type1[id],remark1:remark1[id]},function(data){
if(data=='班级格式错误或不存在,请检查! '){
alert(data);
}else{
alert(data);
location.reload();
}
});
});
});
</script>
html代码:
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="/css/dmcx.css"/>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/cxjl.js"></script>
<script type="text/javascript" src="/My97DatePicker/WdatePicker.js"></script>
<title>MYTITLE</title>
</head>
<body bgcolor="#fff">
<form method="post" name="reqForm" action="/Qtsc/delete">
<table align="center" id="rounded-corner" > <thead>
<tr>
<th scope="col" class="rounded-company">全选<input type='checkbox' name="allsel" onclick="check_all(this,'id[]')"/></th>
<th scope="col" class="rounded">姓名</th>
<th scope="col" class="rounded">学号</th>
<th scope="col" class="rounded">时间</th>
<th scope="col" class="rounded">最初班级</th>
<th scope="col" class="rounded">终于班级</th>
<th scope="col" class="rounded">学籍变动类型</th>
<th scope="col" class="rounded">备注</th>
<th scope="col" class="rounded-q4">改动</th>
<th scope="col" class="rounded-q4">删除</th>
</tr>
</thead> <tbody id="cxjg">
<?php
$k = 0;
$class = $this->class;
$beforeclass = $this->beforeclass;
foreach ($res=$this->studentchange as $key=>$value){
$id=$value["id"];
$url="/qtsc/delete?id[]={$id}";
echo "<tr>";
echo "<td><input type='checkbox' name='id[]' value='".$id."'/></td>";
echo "<td>".$value['name']."</td>"."<td>".$value['student_id']."</td>"."<td>".$value['date']."</td>"."<td>".$beforeclass[$key]."</td>"."<td>".$class[$key]."</td>"."<td>".$value['type']."</td>"."<td>".$value['remark']."</td>";
echo "<td name='".$id."' id='modify'><a href='#' id='alter'><img src='/images/user_edit.png' /></a></td>";
echo '<td><a href="'.$url.'" name="delete"><img src="/images/trash.png" alt="" title="" border="0" /></a></td>';
echo "</tr>";
echo "<tr class='close' name='".$k."' id='".$id."'>
<form method='post' action='/qtsc/update'>
<td></td>
<td><input type='hidden' name='student_id1' value='".$value['student_id']."'</td>
<td>日期<input type='text' name='date1' value='".$value['date']."' class='Wdate' onclick='WdatePicker()'/></td>
<td>最初班级<input type='text' name='beforeclass_id1' value='".$beforeclass[$key]."'/></td>
<td>终于班级<input type='text' name='class_id1' value='".$class[$key]."' /></td>
<td>学籍异动类型<select name='type1' value='".$value['type']."'>
<option value='".$value['type']."'>".$value['type']."</option>
<option value='转专业'>转专业</option>
<option value='试读'>试读</option>
<option value='休学'>休学</option>
</select></td>
<td>备注<input type='text' name='remark1' value='".$value['remark']."'/></td>
<td></td>
<td><input type='button' name='update[]' value='确定改动'/></td>
<td></td>
</form>
</tr>";
$k++;
}
?>
</tbody>
</table>
</form>
<div class="bts">
<a href="/qtsc/qtscadd" class="bt"><span class="bt_lft"></span><strong>加入记录</strong><span class="bt_r"></span></a>
<a href="javascript:void(0)" onclick="isdo()" class="bt"><span class="bt_lft"></span><strong>删除所选</strong><span class="bt_r"></span></a>
<!--<a href="javascript:document.reqForm.submit();" class="bt"><span class="bt_lft"></span><strong>删除所选</strong><span class="bt_r"></span></a>-->
</div>
</body>
</html>
zend framework 在这里我仅仅写控制器中的action。模型省略写,其它的不重要的也不写
//检查学生
public function checkstuAction(){ $stu_id=$this->getRequest()->getParam("stu_id"); $student = new Student();
$res = $student->getStudent($stu_id); $studentchange = new Studentchange();
$res3 = $studentchange->getStuchange($stu_id); $beforeclass_id = $this->getRequest()->getParam('beforeclass_id');
$class_id = $this->getRequest()->getParam('class_id');
$classes = new Classes();
$res1 = $classes->getClassid($beforeclass_id);
$res2 = $classes->getClassid($class_id);
if(count($res)==0&&count($res3)!=0){
echo '此学号不存在,或在学籍异动中该学生已经存在';
exit(); }elseif(count($res1)==0||count($res2)==0){
echo '班级格式错误或不存在。请检查! ';
exit();
}else{
echo 'ok';
exit();
} }
//改动
public function updateAction(){
//取值
$student_id1 = $this->getRequest()->getParam('student_id1');
$date1 = $this->getRequest()->getParam('date1');
$beforeclass_id1 = $this->getRequest()->getParam('beforeclass_id1');
$class_id1 = $this->getRequest()->getParam('class_id1');
$type1 = $this->getRequest()->getParam('type1');
$remark1 = $this->getRequest()->getParam('remark1'); //转化班级名为ID
$classes = new Classes();
$res1 = $classes->getClassid($beforeclass_id1);
$res2 = $classes->getClassid($class_id1);
if(count($res1)==0||count($res2)==0){
echo '班级格式错误或不存在。请检查!';
exit();
} $data = array(
'student_id'=>$student_id1,
'date'=>$date1,
'beforeclass_id'=>$res1[0]['id'],
'class_id'=>$res2[0]['id'],
'type'=>$type1,
'remark'=>$remark1
); $studentchange = new Studentchange();
$db = $studentchange->getAdapter();
$where = $db->quoteInto('student_id=?',$student_id1);
$flag=$studentchange->update($data, $where); // $date1 = array(
// 'class_id'=>$res2[0]['id']
// );
// $student = new Student();
// $db1 = $student->getAdapter();
// $where1 = $db1->quoteInto('id=? ',$student_id1);
// $flag1 = $student->update($data1, $where1); if(count($flag)==0){
echo '您未改动内容或填写格式错误,请检查!';
exit();
}else{
echo '改动成功。';
exit();
}
}
请勿盗版,转载请加上出处http://blog.csdn.net/yanlintao1
用jquery实现隐藏列表表单的显示关闭切换以及Ajax方式改动提交相应的那一行的改动内容。的更多相关文章
- 用jQuery插件来提升SharePoint列表表单用户体验
本文将描述如何通过简单的CSS和jQuery插件提升SharePoint默认的列表表单体验.这些小技巧并不仅仅改善了外观,还提升了可用性. 剩余字数 我们以通知列表为例.通知正文字段假设要求不应该超过 ...
- SharePoint 2013 关于自定义显示列表表单的bug
1.在SharePoint 2013中,我们隐藏列表Dispform页面的ListFormWebPart部件,转而使用自定义显示列表表单进行展示,因为这样更容易定制我们需要的显示: 2.之后发现文件夹 ...
- SharePoint 2013 配置InfoPath 列表表单
转载来源:http://www.cnblogs.com/jianyus/p/3470113.html SharePoint列表,都是通过表单展示,有时候不太符合要求,这时候,我们可以通过定制表单,来是 ...
- [using_microsoft_infopath_2010]Chapter4 使用SharePoint列表表单
本章概要: 1.把SharePoint列表表单转换成InfoPath可用形式 2.使用字段和控件 3.规划表单布局 4.理解列表表单的局限性
- 通过jQuery的Ajax方式来提交Form表单
通过jQuery的Ajax方式来提交Form表单 $.ajax({ url:ajaxCallUrl, type:"POST", cache:true, async:false, d ...
- SharePoint 2013 Designer系列之自定义列表表单
在SharePoint的使用中,默认的样式过于单调经常困扰着我们,其实,SharePoint使用Designer工具,可以很轻松解决这一问题,制作出各式各样漂亮的页面.下面,让我们简单介绍下这一过程. ...
- HTML2列表表单框架
HTML——Hyper Text Markup Language <html>,<head>,<body> 一.基本标签: (一)格式标签:——模型:word工具栏 ...
- layui列表表单
列表: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title ...
- SharePonit online 列表表单定制
1)在O365管理中心,确保启用了站点脚本定制,否则,网站不允许将页面切换到编辑模式. 2)Ribbon上,列表->表单web部件->编辑窗体 如果没有Ribbon,则到列表高级设置,启用 ...
随机推荐
- Java 系列之spring学习--依赖注入(二)
一.依赖注入的三种方式 接口注入,set注入,构造函数注入 二.构造函数注入 2.1.测试类 package test; public class test01 { public String msg ...
- Android之MVP架构
MVP(Model View Presenter)模式是由MVC模式发展而来的,在如今的Android程序开发中显得越来越重要.本篇文章简单讨论了MVP模式的思想. 啥是MVP MVP模式的主要思想是 ...
- lua单链表实现
List = {} --创建一个节点 function List.new(val) return {pnext = nil, value = val} end --往一个节点后添加一个节点 funct ...
- CCS3的过渡、变换、动画以及响应式布局、弹性布局
CSS3 过渡 .变换.动画 在没有CSS3之前,如果页面上需要一些动画效果,要么你自己编写 JavaScript,要么使用 JavaScript 框架(如 jQuery)来提高效率. 但是CSS3出 ...
- [Offer收割]编程练习赛32
气泡图 两两判断关系,dfs. #include<stdio.h> #include<string.h> #include<stdlib.h> #include&l ...
- 洛谷P2181 对角线(组合数)
题目描述 对于一个N个定点的凸多边形,他的任何三条对角线都不会交于一点.请求楚图形中对角线交点的个数. 例如,6边形: 输入输出格式 输入格式: 第一行一个n,代表边数. 输出格式: 第一行输出交点数 ...
- 洛谷P2851 [USACO06DEC]最少的硬币The Fewest Coins(完全背包+多重背包)
题目描述 Farmer John has gone to town to buy some farm supplies. Being a very efficient man, he always p ...
- 【Python3】POP3协议收邮件
初学Python3,做一个email的例子,虽然知道做的很渣渣,还是分享一下吧 POP3协议 POP3全称Post Official Protocol3,即邮局协议的第三个版本,它规定了怎样将个人计算 ...
- SciPy和Numpy处理能力
1.SciPy和Numpy的处理能力: numpy的处理能力包括: a powerful N-dimensional array object N维数组: advanced array slicing ...
- CImage类的使用介绍!
链接参考:http://www.cnblogs.com/juncheng/articles/1600730.html CImage是MFC和ATL共享的新类,它能从外部磁盘中调入一个JPEG.GIF. ...