一些html页面资料
一下没有什么重要的,只是我平时积累的一些页面,紧急时或许会有用,相信过一段时间去东宇(公司分公司)了,这些资料页带不走,还不如留在博客里,趁组长级别们开会去了,他们已经开了一个点啦!我的组长去东宇查看环境去了,哈哈,想想就很美好!
html单选按钮取值:
html:<input type="radio" id="transition"name="pass" value="iscontinue" style="display: none;" class="radio5"/><span style="display: none;" id="sp" >继续贷前审核</span>
<input type="radio" id="transition_reject" name="pass" value="true" checked="checked" class="radio5"/><span id="sp">通过 </span>
<input type="radio" id="transition_reject"name="pass" value="false" class="radio5"/><span id="sp" >不通过</span>
js取值:$("input[name='pass']").each(function() {
if ($(this).is(':checked')) {
if( $(this).val()!="true"){
alert();
}else{
alert();
}
}
});
mybatis:
sql语句循环遍历:
<if test="idList !=null">
<foreach collection="idList" index="index" item="mcs_cre_credit_head_id" open="(" separator="," close=")">
#{mcs_cre_credit_head_id}
</foreach>
</if>
java后台获取时间:格式如:2014-09-29 14:51:21.697
Timestamp sysTime = new Timestamp(System.currentTimeMillis());//获取当前时间
js:分割数据:
str.replace(/\n/g, " ");//替换全部回车或者换行/g是全局的意思
邮箱校验:/^[\.a-zA-Z0-9_-]{4,16}@[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/
用户名由6~20位字母、数字、下划线组成,以字母开头:/^[a-zA-Z][a-zA-Z0-9_]{5,19}$/
密码:/^[\u4e00-\u9fa5]+$/
空格:/\s/
中文版的姓名:/^[\u4E00-\u9FA5]+$/
手机号码:/^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
整数: /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/
小数:/^[0-9]+([.][0-9]{1,2}){0,2}$/
保留小数后两位:/^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/
js创建时间对象:
var now=newDate();//创建时间对象
var year=now.getFullYear();//年
var month=now.getMonth();//月
var date=now.getDate();//日
var day=now.getDay();//星期几
var hour=now.getHours();小时
var minu=now.getMinutes();
var sec=now.getSeconds();
if(confirm("您的余额不足,请充值!")){
location.href = "/resources/html/fundmanage/fundmanage.html";
}
return;
清空form表单input 值:
<form id="searchForm" onsubmit="return false;">
<input id="mortgagee_name" name="mortgagee_name" type="text" />
</form>
js:
$('#searchForm').form('reset');
util.openWindow('editWindow', global_param.context_name+"/corporate/"+node.credit_id+'/openborrowerwind');
@RequestMapping(value="{credit_id}/openborrowerwind",method=RequestMethod.GET)
public String openBorrowerWind(HttpServletRequest request,@PathVariable("credit_id") Integer credit_id,Model model){
if (SysUtil.hasRight(request, "openborrower", GlobalVal.MENU_FUNCTION.VIEW)) {
// corporateService.getBorrowerInfo(request, applyVo)
model.addAttribute("credit_id", credit_id);
SysUtil.getToken(request);
return "/corporate/repaymentEdit.jsp";
}else{
return GlobalVal.STATIC_MENU.NO_RIGHT_PAGE;
}
}
int temp = 0 ;
for (int i = 0 ; i < array.Length - 1 ; i++)
{
for (int j = i + 1 ; j < array.Length ; j++)
{
if (array[j] < array[i])
{
temp = array[i] ;
array[i] = array[j] ;
array[j] = temp ;
}
}
}
<td>
<c:choose>
<c:when test="${item.zylx eq 1}">
<fmt:parseNumber integerOnly="true" value="${item.hqsl }" />
</c:when>
<c:otherwise>${item.hqsl }</c:otherwise>
</c:choose>
</td>
同事说,<fmt标签还有很多属性,多需查看。
json封装:
public Resolution changeProduct(){ Shopgoodsprductys result=shopgoodsprductysService.getysbycode(getProduct()); String str="{"; if(result!=null){ str+="prod_code:'"+result.getSuppliercode()+"',"; str+="product_name:'"+result.getProductname()+"',"; str+="fixed_price:'"+result.getYscpcbj()+"',"; str+="startdate:'"+result.getEffectivetime()+"',"; str+="enddate:'"+result.getInvalidtime()+"',"; str+="prod_category:'"+result.getProducttype()+"'"; } str+="}"; JSONObject json=JSONObject.fromObject(str); return new StreamingResolution("text", new StringReader(json.toString())); }
function changeSuppliercode(){ var product = $("input[name='shopgoodsprductys.suppliercode']").val().trim(); var url=getbasePathUrl('zxxt/Shopgoodsprductys.action?changeProduct=');//url路径 if(product!=null && typeof(product)!='undefined'&&product!=""){ $.get(url,{product:product},function(data){ var ob = eval("("+data+")"); $("input[name='shopgoodsprductys.productname']").val(nullToStr(ob.product_name));//产品名称 $("input[name='shopgoodsprductys.yscpcbj']").val(nullToStr(ob.fixed_price));//原始产品成本价 $("input[name='shopgoodsprductys.effectivetime']").val(nullToStr(ob.startdate));//有效期起 $("input[name='shopgoodsprductys.invalidtime']").val(nullToStr(ob.enddate));//有效期止 var type = nullToStr(ob.prod_category); showSelected(type); }); } }
function showSelected(obj){ console.log("obj:"+obj); if(obj!=null && typeof(obj)!='undefined'&&obj!=""){ var value = document.getElementById("DeviceType").options; for(var i=0;i<value.length;i++){ if(value[i].value==obj){ document.getElementById('DeviceType').options[i].selected=true; } } } }
js包含某个字段并替换掉:
数据格式如下:
<pic>http://img.com/cqlt-pms/Index/01.jsp</pic>
替换操作:
var pi= new RegExp("<pic>","g");
var pi2= new RegExp("</pic>","g");
contents = contents.replace(pi, "<p><img class='pics input_item' alt='' src='");
contents = contents.replace(pi2, "' width='180px' height='120px'/><input type='button' class='delthis' value='删除' onclick='delthist(this)'/></p>");
$("#takesthis").html(contents);
将生成html:
<img class="pics input_item" alt="" src="http://img.com/cqlt-pms/Index/01.jsp" width="180px" height="120px" /><input type="button" class="delthis" value="删除" onclick="delthist(this)"/>
//开始日期不能大于结束日期 function checkTime(){ var tim = true; var startdate=$("input[name='shophqyfjfpz.yxkssj']").val(); var enddate=$("input[name='shophqyfjfpz.yxjssj']").val(); var begin=new Date(startdate.replace(/-/g,"/")); var end=new Date(enddate.replace(/-/g,"/")); if(begin>end){ var htmlmsg = '<small class="validate-msg"><span style="color: #FF0000;">时间大小错误</span></small>'; $("input[name='shophqyfjfpz.yxjssj']").next("small.validate-msg").remove(); $("input[name='shophqyfjfpz.yxjssj']").after(htmlmsg); tim = false; }else{ $("input[name='shophqyfjfpz.yxkssjs']").next("small.validate-msg").remove(); tim=true; } return tim; }
得到的日期格式如下:2016-04-28 10:03:04
mysql查询重复的数据:select user_name,count(*) as count from user_table group by user_name having count>1;
整数正则表达式:/^[1-9]+[0-9]*$/
正整数正则表达式:var reg = /^[0-9]\d*$/;
保留两位小数的正则表达式:/^[0-9]+([.][0-9]{1,2}){0,2}$/
var pram = $("#contentMain tr").map(function(i,e){
if(i != "0"){
var obj = {
"phone":$(this).find("td").eq(1).text(),
"content":$(this).find("td").eq(2).text()
}
}
return obj;
}).get();
正则表达式既能验证手机和座机:/^(010\d{8})|(0[2-9]\d{9})|(0\d{2,3}-\d{7,8})|(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/
jq以什么开头:
$(".coupon-f [class^=radio-pic]").removeClass("radio-pic-on");//class为coupon-f下的以radio-pic开头的class元素。
^= 以什么开头
$= 以什么结尾
~= 包含什么
当input=number时,设置maxlength无效可以酱紫做,可解决:
<input type="number" oninput="if(value.length>3)value=value.slice(0,3)" value="1" minValue="1" /> //最大长度为3
阻止form表单提交:
<form onsubmit="return false;"></form>
暂且写到这里吧,同事下楼出去吹吹风,我也出去一趟,换换心情,今天一个朋友离职了,心情贼啦贼啦不好!