[项目实训]6.8 contest的add功能最终完成
来源:互联网 发布:淘宝退货运费理赔 编辑:程序博客网 时间:2024/06/03 16:56
在和cxa的共同努力下,contest的add终于实现,我在html 文件中完成了script脚本的编写
<script type="text/javascript"> $(document).ready(function () { $("#show_pass").change(function () { if(!document.getElementById("contest_pass")){ $("#contest_open").after("<div class = \"row\" id=\"contest_pass\">"+ "<label class=\"col-sm-2 control-label\">Password:</label>"+ "<div class=\"col-sm-5\">"+ "<input type=\"password\" class=\"form-control\" name=\"password\">"+ "</div>"+ "</div>") } }); $("#hide_pass").change(function () { if(document.getElementById("contest_pass")){ $("div").remove("#contest_pass") } }) $("#show_score").change(function() { $(".score_input").show(); }) $("#hide_score").change(function() { $(".score_input").hide(); }) }); function removeTR(tdobject){ var td=$(tdobject); td.parents("tr").remove(); } function addTR(){ $("#probTable").append("<tr><td><select name=\"originoj\" class=\"form-control\" value=\"\" style=\"width:100px;\" ><option value=\"HDU\">HDU</option><option value=\"FZU\">FZU</option><option value=\"ZOJ\">ZOJ</option></select></td><td><input type=\"text\" class=\"form-control\" name=\"prob\" oninput=\"getTitle(event,this)\" onpropertychange=\"getTitle(event,this)\"></td><td><input type=\"text\" class=\"form-control\" value=\"No Such Problem\" name=\"title\" disabled=\"disabled\" style=\"width:200px;\"></td><td hidden=\"hidden\" class=\"score_input\"><input type=\"text\" class=\"form-control\" name=\"score\" value = \"1\" style=\"width:80px;\"></td><td onclick=\"removeTR(this)\"><center><button type=\"button\" class=\"btn btn-danger\">Remove</button></center></td></tr>") if($("input[name='type']:checked").val() == "custom"){ $(".score_input").show(); }else{ $(".score_input").hide(); } } function getTitle(event,inputobject){ var trobject = $(inputobject).parents("tr") var originoj = $(trobject).children("td").eq(0).children("select").eq(0).val() var probid = $(inputobject).val() var title_obj = $(trobject).children("td").eq(2).children("input").eq(0) $.ajax({ type: 'get', url: "/contest/addcontest/get_problem_title/?originoj=" + originoj+"&probid="+probid, success: function (responseData) { $(title_obj).val(responseData); } }) } function addcontest_submit(){ //author type openness title begin duration var problems = "$" var ok = 0 $("#probTable tr").each(function(){ var originoj = $(this).children("td").eq(0).children("select").eq(0).val() var probid = $(this).children("td").eq(1).children("input").eq(0).val() var title = $(this).children("td").eq(2).children("input").eq(0).val() var score = $(this).children("td").eq(3).children("input").eq(0).val() if(title == "No Such Problem" || isNaN(score)){ //alert(title+"/"+score) ok = ok + 1 }else{ problems = problems + originoj + "|" + probid + "|" + score + "$" } }) //alert(problems) if(ok < 2){ var pass = "" var obj = $('input[name="password"]') if(obj.length != 0){ pass = $('input[name="password"]').val() } detail = { "author" : $('input[name="author"]').val(), "type" : $('input[name="type"]').val(), "openness" : $('input[name="openness"]').val(), "password" : pass, "title" : $('input[name="title"]').val(), "begin" : $('input[name="begin"]').val(), "duration" : $('input[name="duration"]').val(), "problems" : problems } $.ajax({ type : "post", url : "/contest/addcontest/submit/", data : detail, success : function(responseData){ if(responseData == "begin error"){ alert("Please check your begin-time format!") }else if(responseData == "duration error"){ alert("Please check your duration format!") }else if(responseData == "error"){ alert("Occur a unexcepted error!") }else{ window.location.href = responseData; } }, error : function(responseData){ alert("Add contest error!") alert(responseData) } }) }else{ alert("Please check your problems!") } } </script>
阅读全文
0 0
- [项目实训]6.8 contest的add功能最终完成
- [项目实训]6.4 contest的add功能起步
- 最终完善的银行项目
- 标签的功能完成
- 更新功能的完成
- 完成的项目
- 完成90%的项目
- 开发完成端口服务器过程中,实现post两次完成调用的问题和最终解决
- xml完成配置的功能
- 已完成的评价功能
- runtime完成的功能举例
- 完成对话框收缩的功能
- 完成定时功能的类
- [项目实训]5.28 contest前端硬苟日志
- HydroCMS完成项目标签功能和自定义目录修改功能
- 第十三周 项目5:(2)阅读程序,完成类似字符串复制的功能
- 第十三周 项目5:(1)阅读程序,完成类似的字符串统计功能
- 第13周项目5-完成类似字符串复制的功能
- 在js中怎样获得checkbox里选中的多个值?
- XWPFDocument读取word并修改发送
- Swift装饰者模式
- EIGRP协议配置
- mysql 替换字符串
- [项目实训]6.8 contest的add功能最终完成
- php 字符串压缩
- 从高考到程序员
- 放在HTML里的哪一部分JavaScripts会在页面加载时被执行?
- 一步一步学ROP之Android ARM 32位篇 -- 阅读笔记及实践
- JavaScript对Json的增删改属性
- SSM框架详细整合教程
- 如何使用 Java 中的数组
- [MyEclipse手册]JSP、HTML页面排版