您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

jquery实现预览提交的表单代码分享_jquery

2024/6/18 7:59:58发布40次查看
预览表单,查看后确认提交或者返回重填
xml/html code
复制代码 代码如下:
registeration
username :
password :
email :
country :
select country 
    united states 
    united kingdom 
    china
gender :
male
female
subscribe us :
javascript code
复制代码 代码如下:
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;}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product