请勿盗版,转载请加上出处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方式改动提交相应的那一行的改动内容。的更多相关文章

  1. 用jQuery插件来提升SharePoint列表表单用户体验

    本文将描述如何通过简单的CSS和jQuery插件提升SharePoint默认的列表表单体验.这些小技巧并不仅仅改善了外观,还提升了可用性. 剩余字数 我们以通知列表为例.通知正文字段假设要求不应该超过 ...

  2. SharePoint 2013 关于自定义显示列表表单的bug

    1.在SharePoint 2013中,我们隐藏列表Dispform页面的ListFormWebPart部件,转而使用自定义显示列表表单进行展示,因为这样更容易定制我们需要的显示: 2.之后发现文件夹 ...

  3. SharePoint 2013 配置InfoPath 列表表单

    转载来源:http://www.cnblogs.com/jianyus/p/3470113.html SharePoint列表,都是通过表单展示,有时候不太符合要求,这时候,我们可以通过定制表单,来是 ...

  4. [using_microsoft_infopath_2010]Chapter4 使用SharePoint列表表单

    本章概要: 1.把SharePoint列表表单转换成InfoPath可用形式 2.使用字段和控件 3.规划表单布局 4.理解列表表单的局限性

  5. 通过jQuery的Ajax方式来提交Form表单

    通过jQuery的Ajax方式来提交Form表单 $.ajax({ url:ajaxCallUrl, type:"POST", cache:true, async:false, d ...

  6. SharePoint 2013 Designer系列之自定义列表表单

    在SharePoint的使用中,默认的样式过于单调经常困扰着我们,其实,SharePoint使用Designer工具,可以很轻松解决这一问题,制作出各式各样漂亮的页面.下面,让我们简单介绍下这一过程. ...

  7. HTML2列表表单框架

    HTML——Hyper Text Markup Language <html>,<head>,<body> 一.基本标签: (一)格式标签:——模型:word工具栏 ...

  8. layui列表表单

    列表: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title ...

  9. SharePonit online 列表表单定制

    1)在O365管理中心,确保启用了站点脚本定制,否则,网站不允许将页面切换到编辑模式. 2)Ribbon上,列表->表单web部件->编辑窗体 如果没有Ribbon,则到列表高级设置,启用 ...

随机推荐

  1. Node.js:安装配置

    ylbtech-Node.js:安装配置 1.返回顶部 1. ode.js 安装配置 本章节我们将向大家介绍在window和Linux上安装Node.js的方法. 本安装教程以Node.js v4.4 ...

  2. java语言的运行机制

    计算机高级编程语言按其程序的执行方式可分为编译型语言和解释型语言. 编译型语言是指使用专门的编译器,针对特定的操作系统将源程序代码一次性翻译成计算机能识别的机器指令.例如C.C++等都属于编译型语言. ...

  3. Elasticsearch之cur查询索引

    前提, Elasticsearch之curl创建索引库 Elasticsearch之curl创建索引 Elasticsearch之curl创建索引库和索引时注意事项 Elasticsearch之cur ...

  4. jar运行main函数的方法

    当把java项目打包成jar后,如何运行main函数呢? 第一种:指定运行类: java -cp test.jar com.ming.test.Test 第二种:在MANIFEST.MF里配置了Mai ...

  5. 利用Aspose.Cells导出Datatable数据

    面对一些的格式各样的到处数据的要求,自学了一点 Aspose.Cells中操作Excel知识,如下代码: /// <summary> /// DataTable导出Excel /// &l ...

  6. .net web api跨域问题

    No 'Access-Control-Allow-Origin' Ajax跨域访问解决方案   No 'Access-Control-Allow-Origin' header is present o ...

  7. window 10 多版本激活工具

    window 10 通用版激活工具 云盘地址:https://pan.baidu.com/s/1bo3L4Kn 激活工具网站:http://www.tudoupe.com/win10/win10jih ...

  8. CI中的url相关函数以及路由设置和伪静态技术

    当使用CI框架进行开发时,我们的一些数据传递的URL不应该写死,可以使用如下方法:比如说我们需要表单提交一个数据: 1.在controller控制器中我们需要先创建一个加载helper和视图的方法: ...

  9. P3808 【模版】AC自动机(简单版)

    题目背景 这是一道简单的AC自动机模版题. 用于检测正确性以及算法常数. 为了防止卡OJ,在保证正确的基础上只有两组数据,请不要恶意提交. 题目描述 给定n个模式串和1个文本串,求有多少个模式串在文本 ...

  10. TD中INPUT的宽度设置

    最近在用C#做Web程序时,碰到一个问题: 将TextBox的asp控件放在Table中的TD里面时,不设置宽度,自动会将TD撑的很大. 查看运行后页面的源代码发现,其实TextBox控件最终在客户端 ...