【jquery对表单操作2】教程文章相关的互联网学习教程文章

JQuery对表单元素的基本操作使用总结

select下拉列表onChange事件之JQuery实现: JQuery: $(document).ready(function () { $("#selectMenu").bind("change", function () { if ($(this).val() == "pro1") { $("#pro1").slideDown(); $("#pro2").slideUp(); } else if($(this).val() =="pro2") { $("#pro2").slideDown(); $("#pro1").slideUp(); } }); }); HTML: <select id="selectMenu"> <option value="" >Please select product below</option> <opt...

jquery序列化表单以及回调函数的使用示例

在开发项目中,将前台的值传给后台,有时的JSP表单中的值有一两个,也有全部的值,如果这时一个个传,必定不是很好的办法,所以使用jQuery提供的表单序列化方法,可以很好的解决这个问题,同时可以封装成通用的函数,执行成功可以调用各自的回调函数,实现各自的功能。 代码如下: function queryUserInfo(actionUrl,formId,fun){ var params=new Object(); //声明数组 $.each($("#"+formId).serializeArray(),function(index,pa...

jquery的attr方法禁用表单元素禁用输入内容

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>jquery禁用输入内容</title> <script type="text/javascript" src="jquery-1.4.4.js"></script> <script type="text/javascript"> $(function(){ $("#name").attr("disabled","disabled"); $("#note").attr("disabl...

jQuery select表单提交省市区城市三级联动核心代码【图】

jQuery select表单提交省市区城市三级联动,引用的是“jquery-1.7.min”类库,地区码查询地区名用数组存在AreaData_min,下面摘要部分代码: SelectArea.htm文件 代码如下:<!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" ...

jquery动态改变form属性提交表单

有些情况下,同一个form在不同的情况下提交到不同的处理动作,可以在js中动态改变form的属性,满足不同条件的form提交需求。 如: 代码如下:<form id="form" name="form" method="POST" enctype="multipart/form-data" action="action1.jsp" target="iframe"> <input type="file" name="file" id="file" class="input_text80"></input> <input id="name" name="name"/> <input type="button" value="更新到探测点" onClick="javas...

使用jquery修改表单的提交地址基本思路

基本思路: 通过使用jquery选择器得到对应表单的jquery对象,然后使用attr方法修改对应的action 示例程序一: 默认情况下,该表单会提交到page_one.html 点击button之后,表单的提交地址就会修改为page_two.html 代码如下:<!doctype html> <html> <head> <meta charset="utf-8"> <title>jquery test</title> <script src="jquery-1.11.1.min.js"></script> </head> <body> <div> <form action="page_one.html" id="qianshou"> <in...

jquery实现预览提交的表单代码分享【图】

预览表单,查看后确认提交或者返回重填XML/HTML Code代码如下: <form class="mform" id="myform" method="POST" id="myform" action=""> <fieldset> <legend>Registeration</legend> <table cellspacing="0"> <tbody> <tr> <td><label for="u_name"> Username :</label></td> <td><input type="text" name="uname" id="u_name"> <td> </tr> <tr> <td><label for="u_pwd"...

jQuery事件之键盘事件(ctrl+Enter回车键提交表单等)

键盘事件处理所有用户在键盘敲击的情况,不管在文本输入区域内部还是外部。键盘事件在不同的浏览器中作用的范围是不一样的,通常这种键盘事件可以作用于 Form元素,a标签元素,window ,document这样的元素上。在所有可以获得交点的元素上是可以触发键盘事件的,可以获得焦点的元素可以这样理解,在使用Tab键的时候可以跳跃到的元素就是可以使用键盘事件的元(在没有为这些元素设置tabindex属性值的情况下,当tabindex设置为负数的时...

使用jQuery重置(reset)表单的方法

由于JQuery中,提交表单是像下面这样的: 代码如下:$(#yigeform).submit()所以,想当然的认为,重置表单,当然就是像下面这样子喽: 代码如下:$(#yigeform).reset()但是,不幸的是,这样写的话,会有一个让你很郁闷的结果,那就是,表单无法重置! 后来,上网查了一下,说是,JQuery中没有reset方法,经核对,果然是没有。 那有么没有办法通过JQuery来重置表单呢,答案是有的,不过是一种间接的方法,如下: 代码如下:$(#yigeform)...

jquery序列化表单去除指定元素示例代码

代码如下:<html> <head> </head> <body> <form name="form1"> <input type="hidden" name="page1" class="flau_u_ro" value="1"></input> <input type="hidden" name="pageno" value="1"></input> <input name="pagename" value=""></input> <select name=pageflag> <option value=1 >是</option> <option value=0 selected=selected>否</option> </select> </form> </body> <script text="text/javascript" src="jquery-1.8.2.js"...

jquery选择符快速提取web表单数据示例【图】

本人比较懒,在做web时,当遇到要重复多次同样的事时,就想找一种省时省力的方法。 以前在web提交表单并且需要验证用户输入时,在提取用户输入信息时,都要在js用到document.getElementById(),这样一个两个表单域还行,但有很多时(我就遇到过有十几个的情况)看看都眼花,所以个人就比较反感这种方式,不过还好,我自己瞎琢磨,利用jquery找到了一种方便的方法。 我给需要提交数据每个表单域添加了一个额外的属性,用自己额外定义...

jquery自动将form表单封装成json的具体实现

前端页面: 代码如下:<span style="font-size:14px;"> <form action="" method="post" id="tf"> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> <th> 姓名: </th> <td> <input type="text" id="txtUserName" name="model.UserName" /> </td> <th> 联系手机: </th> <td> <input type="text" name="model.Mobile" id="txtMobile" maxlength="11" /> </td> <th> 密码: </th> <td> <input type="password"...

使用jQuery时Form表单元素ID和name命名大忌

在做自己的毕业设计的时候将自己的表单元素ID和name命名为了nodeName: 代码如下:<form> <input type="text" name="nodeName" id="nodeName"> ........... </form> 在chrome浏览器下可以看到这么个错误: Uncaught TypeError: Object #<HTMLInputElement> has no method toLowerCase 经过分析后发现原来是表单元素命名的原因,修改一下就好了。

jquery form表单序列化为对象的示例代码

代码如下:$.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name]) { if (!o[this.name].push) { o[this.name] = [ o[this.name] ]; } o[this.name].push(this.value || ); } else { o[this.name] = this.value || ; } }); return o; }

jquery序列化form表单使用ajax提交后处理返回的json数据

1、返回json字符串:代码如下: /** 将一个字符串输出到浏览器 */ protected void writeJson(String json) { PrintWriter pw = null; try { servletResponse.setContentType("text/plain;charset=UTF-8"); pw = servletResponse.getWriter(); pw.write(json); pw.flush(); pw.close(); } catch (IOException e) { e.printSta...