jquery实现预览提交的表单代码分享_jquery
预览表单,查看后确认提交或者返回重填
XML/HTML Code
JavaScript Code
<script> <BR>$(document).ready(function() { <BR> $('#myform').previewForm(); <BR>}); <BR></script>
previewForm.js
(function($){
$.fn.previewForm = function(options){
var form_settings = $.extend({
identifier : 'label',
show_password : true,
extratext : 'Do You Want To submit',
yes : 'yes',
no : 'no',
title : 'Please preview'
}, options);
var dia_log;
var renderBUTTON;
var this_frm;
this_frm = $(this);
$(this).submit(function (){
if($('#pfomdata').length){
return true;
}
dia_log="";
var needle_cnfrm;
if(this.id.length > 0){ needle_cnfrm = '#'+this.id+' label'; }
else { needle_cnfrm = '.'+$(this).attr('class')+' label'; }
$(needle_cnfrm).each(function(i,val) {
if($(this).text().length >2){
what_t= $('#'+$(this).attr('for')) ;
switch(what_t.prop('type')){
case 'password':
if(!form_settings.show_password)
dia_log +=$(this).text() + " your selected password
";
else
dia_log +=$(this).text() +what_t.val()+"
";
break;
case 'select-one':
dia_log +=$(this).text() +$('#'+$(this).attr('for')+' option:selected').text()+"
";
break;
case 'radio':
if( what_t.is(':checked'))
dia_log +=$(this).text() +' '+what_t.val()+"
";
break;
case 'checkbox':
if( what_t.is(':checked'))
dia_log +=$(this).text() +' '+what_t.val()+"
";
break;
case 'undefined':
break;
default:
dia_log +=$(this).text() +what_t.val()+"
";
break;
}
}
});
dia_log = dia_log.replace('undefined', '');
renderBUTTON="";
renderBUTTON += ''+form_settings.yes+'';
renderBUTTON += ''+form_settings.no+'';
var renderTemplate = [
'
'
'
',form_settings.title,'
','
',dia_log,'
','
',form_settings.extratext,'
','
renderBUTTON,
'
].join('');
$(renderTemplate).hide().appendTo('body').fadeIn();
$(".form_yes") .click(function(){
var input = $("").attr("type", "hidden").attr("id", "pfomdata").val("true");
this_frm.append($(input));
this_frm.submit();
});
$(".form_no") .click(function(){
$('#previewOverlay').fadeOut(function(){
$(this).remove();
});
});
return false;
});
}
})(jQuery);
previewForm.css
#previewOverlay{
width:100%;
height:100%;
position:fixed;
top:0;
left:0;
background:url('ie.png');
background: -moz-linear-gradient(rgba(11,11,11,0.1), rgba(11,11,11,0.6)) repeat-x rgba(11,11,11,0.2);
background:-webkit-gradient(linear, 0% 0%, 0% 100%, from(rgba(11,11,11,0.1)), to(rgba(11,11,11,0.6))) repeat-x rgba(11,11,11,0.2);
z-index:100000;
}
#previewBox{
background:url('body_bg.jpg') repeat-x left bottom #e5e5e5;
width:460px;
position:fixed;
left:50%;
top:50%;
margin:-130px 0 0 -230px;
border: 1px solid rgba(33, 33, 33, 0.6);
-moz-box-shadow: 0 0 2px rgba(255, 255, 255, 0.6) inset;
-webkit-box-shadow: 0 0 2px rgba(255, 255, 255, 0.6) inset;
box-shadow: 0 0 2px rgba(255, 255, 255, 0.6) inset;
}
#previewBox h1,
#previewBox p{
font:26px/1 'Cuprum','Lucida Sans Unicode', 'Lucida Grande', sans-serif;
background:url('header_bg.jpg') repeat-x left bottom #f5f5f5;
padding: 18px 25px;
text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.6);
color:#666;
}
#previewBox h1{
letter-spacing:0.3px;
color:#888;
}
#previewBox p{
background:none;
font-size:16px;
line-height:1.4;
padding-top: 7px;
}
#previewButtons{
padding:15px 0 25px;
text-align:center;
}
#previewBox .button{
display:inline-block;
background:url('buttons.png') no-repeat;
color:white;
position:relative;
height: 33px;
font:17px/33px 'Cuprum','Lucida Sans Unicode', 'Lucida Grande', sans-serif;
margin-right: 15px;
padding: 0 35px 0 40px;
text-decoration:none;
border:none;
}
#previewBox .button:last-child{ margin-right:0;}
#previewBox .button span{
position:absolute;
top:0;
right:-5px;
background:url('buttons.png') no-repeat;
width:5px;
height:33px
}
#previewBox .form_yes{ background-position:left top;text-shadow:1px 1px 0 #5889a2;}
#previewBox .form_yes span{ background-position:-195px 0;}
#previewBox .form_yes:hover{ background-position:left bottom;}
#previewBox .form_yes:hover span{ background-position:-195px bottom;}
#previewBox .form_no{ background-position:-200px top;text-shadow:1px 1px 0 #707070;}
#previewBox .form_no span{ background-position:-395px 0;}
#previewBox .form_no:hover{ background-position:-200px bottom;}
#previewBox .form_no:hover span{ background-position:-395px bottom;}

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

jQuery引用方法详解:快速上手指南jQuery是一个流行的JavaScript库,被广泛用于网站开发中,它简化了JavaScript编程,并为开发者提供了丰富的功能和特性。本文将详细介绍jQuery的引用方法,并提供具体的代码示例,帮助读者快速上手。引入jQuery首先,我们需要在HTML文件中引入jQuery库。可以通过CDN链接的方式引入,也可以下载

jQuery中如何使用PUT请求方式?在jQuery中,发送PUT请求的方法与发送其他类型的请求类似,但需要注意一些细节和参数设置。PUT请求通常用于更新资源,例如更新数据库中的数据或更新服务器上的文件。以下是在jQuery中使用PUT请求方式的具体代码示例。首先,确保引入了jQuery库文件,然后可以通过以下方式发送PUT请求:$.ajax({u

jQuery是一款广泛应用于前端开发的快速、小巧、功能丰富的JavaScript库。自2006年发布以来,jQuery已经成为众多开发者的首选工具之一,但是在实际应用中,它也不乏一些优势和劣势。本文将深度剖析jQuery的优势与劣势,并结合具体的代码示例进行说明。优势:1.简洁的语法jQuery的语法设计简洁明了,可以大大提高代码的可读性和编写效率。比如,

jQuery如何移除元素的height属性?在前端开发中,经常会遇到需要操作元素的高度属性的需求。有时候,我们可能需要动态改变元素的高度,而有时候又需要移除元素的高度属性。本文将介绍如何使用jQuery来移除元素的高度属性,并提供具体的代码示例。在使用jQuery操作高度属性之前,我们首先需要了解CSS中的height属性。height属性用于设置元素的高度

标题:jQuery小技巧:快速修改页面所有a标签的文本在网页开发中,我们经常需要对页面中的元素进行修改和操作。在使用jQuery时,有时候需要一次性修改页面中所有a标签的文本内容,这样可以节省时间和精力。下面将介绍如何使用jQuery快速修改页面所有a标签的文本,同时给出具体的代码示例。首先,我们需要引入jQuery库文件,确保在页面中引入了以下代码:<

标题:使用jQuery修改所有a标签的文本内容jQuery是一款流行的JavaScript库,被广泛用于处理DOM操作。在网页开发中,经常会遇到需要修改页面上链接标签(a标签)的文本内容的需求。本文将介绍如何使用jQuery来实现这个目标,并提供具体的代码示例。首先,我们需要在页面中引入jQuery库。在HTML文件中添加以下代码:

jQuery是一种流行的JavaScript库,被广泛用于处理网页中的DOM操作和事件处理。在jQuery中,eq()方法是用来选择指定索引位置的元素的方法,具体使用方法和应用场景如下。在jQuery中,eq()方法选择指定索引位置的元素。索引位置从0开始计数,即第一个元素的索引是0,第二个元素的索引是1,依此类推。eq()方法的语法如下:$("s

如何判断jQuery元素是否具有特定属性?在使用jQuery操作DOM元素时,经常会遇到需要判断元素是否具有某个特定属性的情况。这种情况下,我们可以借助jQuery提供的方法来轻松实现这一功能。下面将介绍两种常用的方法来判断一个jQuery元素是否具有特定属性,并附上具体的代码示例。方法一:使用attr()方法和typeof操作符//判断元素是否具有特定属
