$("#precinct").change(function(){ $("#ptype").val("");//Reset all $("#stype" ).html(""); $("#stype").append(""); }) ;
//Listen to the patent type change event $("#ptype").change(function(){ var ptype = $(this); var atype = $(this).val();//Object value var pid = $("#precinct").val(); if (!ptype.data(atype)) {//If you get the value from the cache, you don’t need to interact with the server anymore $.post("Main/PatentSubsidy/getSubsidy",{askfor:atype,precinct:pid }, function(json){//Return json object $("#stype").html("");//Clear#stypeDrop-down box for(var i=0;i//Add a $("#stype").append( ""); }; ptype.data(atype, json) ; //Add the #ptype value as the key to the cache },'json'); }else{ var json = ptype.data(atype); //Get the cache $ ("#stype").html(""); for(var i=0;i//Add a $("#stype"). append(""); }; } }) ;
public void getSubsidy(){ String askfor=null,precinct=null; if(null!= getPara("askfor")&&!"".equals(getPara("askfor"))){ askfor=getPara("askfor"); if(null!=getPara("precinct")&&! "".equals(getPara("precinct"))){ precinct=getPara("precinct"); } }else{ renderJson("[{"id":"" ,"value":"--Please select--"}]");//Pass null value and return } String sql = "select s.id, s.subsidy_type, p.name from org_subsidy_flow s, tab_precinct p where s.enabled = 'true' and p.status = '1' and s.patent_type = '" askfor "' and s.precinct = p.id"; if(null!=precinct&&! "".equals(precinct)){ sql = " and p.id = " precinct; } sql = " order by p.id, s.id"; Listif(sf.size()!=0){ StringBuffer buffer = new StringBuffer(); for(int i=0;i< sf.size();i ){ buffer.append("{"id" : "" sf.get(i).getInt("id") "" , "value" : "" sf.get( i).getStr("subsidy_type") " -- " sf.get(i).getStr("name") ""},"); } if(buffer.length()!=0 ){ renderJson("[" buffer.substring(0, buffer.length()-1).toString() "]"); } }else{ renderJson("[ {"id":"","value":"--Please select--"}]"); } }
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn