• 解析url动态构建form提交表单


    <a id ="rnavLink" href ="#"  postURL="http://localhost:8080/GE/jsp/PclYxAction.jsp?DATATYPE_OP=&DATATYPE_COND=&DATATYPE_COND2=&DESCRIPTION_OP=&DESCRIPTION_COND=&DESCRIPTION_COND2=&FIELDNAME_OP=&FIELDNAME_COND=&SOURCENAME_OP=&SOURCENAME_COND=&PAGESIZE=10&ENQUIREID=test2&SYS.USERID_COND=null&SYS.PROCESSDATE_COND=null&ORDERBY_CNT=0&FUNCID=0&runbatButton=1" target="_blank">搜索</a>

    $(document).ready(function() {
    $('#rnavLink').click(function() {
    var p = $(this).attr('postURL').split('?');
    alert(p);
    var action = p[0];
    var params = p[1].split('&');
    var form = $('<form/>', {action:action, method:'post'}).appendTo('body');
    for (var i in params) {
    var tmp = params[i].split('=');
    var key = tmp[0], value = tmp[1];
    $('<input/>', {type:'hidden', name:key, value:value}).appendTo(form);
    }
    alert(form);
    $(form).submit();
    return false;
    });
    });

    <script language="Javascript">

    $(document).ready(function() {
    $("a").each(function (){
    var loc = this.href ;
    var loc1 ="'"+loc+"'";
    // var obj = "submit_form("+loc1+")";
    this.href ="###";
    loc = decodeURIComponent(loc);
    $(this).attr("postURL" , loc);
    //$(this).attr("onclick" , obj);
    });
    $("a").click(function(){
    //alert("postURL:"+$(this).attr("postURL"));
    var loc = $(this).attr("postURL") ;
    //loc = decodeURIComponent (loc);
    submit_form(loc );
    });
    });
    function submit_form(loc ){
    var framid = "fraRightFrame";
    var p = loc.split('?');
    var action = p[0] ;
    if(p.length>1){
    var params = p[1].split('&');
    // alert(p);
    var form = $('<form/>', {action:action, method:'post' , target:framid}).appendTo('body');
    for (var i in params) {
    params[i] = trim(params[i]);
    var tmp = params[i].split('=');

    var key = tmp[0], value = tmp[1];
    if(value !=null && value.length>0){
    //value =value.replace("%20" ," ");
    // alert("key:"+key +"&value:"+value);
    //value = encodeURI(value);
    $('<input/>', {type:'hidden', name:key, value:value}).appendTo(form);
    }
    // action = action + "&"+key +"="+value ;
    // $('<input/>', {type:'hidden', name:key, value:value}).appendTo(form);
    }
    }
    //action = encodeURI(action);
    //alert("action:"+action);

    $(form).submit().remove();

    }</script>

  • 相关阅读:
    OCP-1Z0-052-V8.02-44题
    Oracle DB 使用调度程序自动执行任务
    OCP-1Z0-053-V12.02-497题
    OCP-1Z0-053-V12.02-513题
    OCP-1Z0-053-V12.02-650题
    OCP-1Z0-053-V12.02-680题
    OCP-1Z0-052-V8.02-42题
    OCP-1Z0-052-V8.02-130题
    OCP-1Z0-052-V8.02-132题
    Mysql中的from_unixtime,unix_timestamp 整型与datetime 字符串之间的转换
  • 原文地址:https://www.cnblogs.com/leiyf/p/5649461.html
Copyright © 2020-2023  润新知