加入收藏 | 设为首页 | 会员中心 | 我要投稿 桂林站长网 (https://www.0773zz.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html 提交表单,图片和文字一起提交,图片存入服务器,图片地址

发布时间:2020-12-24 14:11:31 所属栏目:资源 来源:网络整理
导读:html pre class="has" !DOCTYPE html head meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0" / meta charset="UTF-8"gt; titleTitle/title script src="https://ajax.aspnetcdn.

if (!semantic && form.clk) {
// input type=='image' are not found in elements array! handle it here
var $input = $(form.clk),input = $input[0];
n = input.name;
if (n && !input.disabled && input.type == 'image') {
a.push({name: n,value: $input.val()});
a.push({name: n+'.x',value: form.clk_y});
}
}
return a;
};

/**

  • Serializes form data into a 'submittable' string. This method will return a string
  • in the format: name1=value1&name2=value2
    */
    $.fn.formSerialize = function(semantic) {
    //hand off to jQuery.param for proper encoding
    return $.param(this.formToArray(semantic));
    };

/**

  • Serializes all field elements in the jQuery object into a query string.
  • This method will return a string in the format: name1=value1&name2=value2
    */
    $.fn.fieldSerialize = function(successful) {
    var a = [];
    this.each(function() {
    var n = this.name;
    if (!n) {
    return;
    }
    var v = $.fieldValue(this,successful);
    if (v && v.constructor == Array) {
    for (var i=0,max=v.length; i < max; i++) {
    a.push({name: n,value: v[i]});
    }
    }
    else if (v !== null && typeof v != 'undefined') {
    a.push({name: this.name,value: v});
    }
    });
    //hand off to jQuery.param for proper encoding
    return $.param(a);
    };

/**

  • Returns the value(s) of the element in the matched set. For example,consider the following form:
  • <input name="B" type="checkbox" value="B2"/>
  • var v = $('input[type=text]').fieldValue();
  • // if no values are entered into the text inputs
  • v == ['','']
  • // if values entered into the text inputs are 'foo' and 'bar'
  • v == ['foo','bar']
  • var v = $('input[type=checkbox]').fieldValue();
  • // if neither checkbox is checked
  • v === undefined
  • // if both checkboxes are checked
  • v == ['B1','B2']
  • var v = $('input[type=radio]').fieldValue();
  • // if neither radio is checked
  • v === undefined
  • // if first radio is checked
  • v == ['C1']
  • The successful argument controls whether or not the field element must be 'successful'
  • (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
  • The default value of the successful argument is true. If this value is false the value(s)
  • for each element is returned.
  • Note: This method always returns an array. If no valid value can be determined the
  • array will be empty,otherwise it will contain one or more values.
    */
    $.fn.fieldValue = function(successful) {
    for (var val=[],i=0,max=this.length; i < max; i++) {
    var el = this[i];
    var v = $.fieldValue(el,successful);
    if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
    continue;
    }
    if (v.constructor == Array) {
    $.merge(val,v);
    }
    else {
    val.push(v);
    }
    }
    return val;
    };

/**

  • Returns the value of the field element.
    */
    $.fieldValue = function(el,successful) {
    var n = el.name,t = el.type,tag = el.tagName.toLowerCase();
    if (successful === undefined) {
    successful = true;
    }

    if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
    (t == 'checkbox' || t == 'radio') && !el.checked ||
    (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
    tag == 'select' && el.selectedIndex == -1)) {
    return null;
    }

    if (tag == 'select') {
    var index = el.selectedIndex;
    if (index < 0) {
    return null;
    }
    var a = [],ops = el.options;
    var one = (t == 'select-one');
    var max = (one ? index+1 : ops.length);
    for(var i=(one ? index : 0); i < max; i++) {
    var op = ops[i];
    if (op.selected) {
    var v = op.value;
    if (!v) { // extra pain for IE...
    v = (op.attributes && op.attributes.value && !(op.attributes.value.specified)) ? op.text : op.value;
    }
    if (one) {
    return v;
    }
    a.push(v);
    }
    }
    return a;
    }
    return $(el).val();
    };

(编辑:桂林站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

推荐文章
    热点阅读