1. $("#trinvoicenumber").css("display",""); 显示
$("#trinvoicenumber").css("display","none");不显示
document.getElementById("tddiffamountreason").style.display = "block";显示
document.getElementById("tddiffamountreason").style.display = "none"; 不显示
$("#co").attr("disabled","true"); 置灰
$("#Currency").attr("disabled",false);取消置灰
$("#nextButton").attr("disabled","disabled");置灰
$('#areaSelect').attr("disabled",""); 取消置灰
$("#Currency").removeAttr("disabled");取消置灰
$("img[name='commonImg']").attr("style","display:'none'");隐藏图片
$("img[name='commonImg']").attr("style","display:''");显示
--默认选中value值为02的下拉选项
$("select[name='prpjinvoice.invoicetype'] option[value='02']").attr("selected",true);
2. 获取下拉列表中,被选中的text值
$("#billingobjcode option:selected").text();
3. 获取下拉列表中,被选中的val值
$("#billingobjcode option:selected").val();
4. url = "项目名/ecexpapply4Business/ecea_showInvoiceDetail.do?verifytype="+type+"&businessGroup="+businessGroup;
openwindow(url,"","1000","800");
5. 提交form表单
url = 项目名 + "/billingDetailed/prepareQeryBillDetailList.do?"+param;
$("#fm").attr("action",url).submit();
$("#fm").attr("action",contextRootPath + "/invoice/addInvoiceRepeat.do").submit();
6. var param = {
"username" : $("#username").val(),
"password" : $("#password").val()
};
$.ajax({
type:"POST",
url:url, --可以从根路径写,也可以直接写
data:param, {"username" : $("#username").val(),"password" : $("#password").val()},
dataType:"json",
success:function(obj){
业务逻辑实现
},
error:function(obj){
业务逻辑实现
}
$.post(url,null,callback,'JSON');
function callback(data){
if(data!=null){
业务逻辑实现
}
$.post(项目名+'/ecdcompany/ecdcompany_delete.do?', $("#ecdCompanyQueryFormId").serialize(), function (obj){
alert(eval("("+obj+")").msg);
}
其中:$("#ecdCompanyQueryFormId").serialize() 可以在后台获取js中,含有name属性的值,封装成DTO,有name属性的,这个DTO对应的属性就有值
7. var all=$("#all");
var emp=$("#select").length;
for(int i=;i<emp.length;i++){
if(all.checked==true){
emp[i].checked=true;
}else{
emp[i].checked=false;
}
8. --打开新窗口(可以通过url进入action,再返回到一个jsp)
openwindow(url,"税控时间确认","600","400");
window.open(url,"发票关联多张单据明细","width=800","height=500");
window.opener. --操作父窗口
opener.location.reload(); 刷新父界面
local.href="1.html"; --跳转到某个界面
window.opener.location="2.html"; --把当前的2.html在父窗口打开
window.opener.document.getElementById("businessGroup").value = ''; 改变父窗口中id域值
9. var arrThisPayreffee=$("input[id='thisPayreffee']"); --遍历已知table中每一列总值
var sumData = new Number(0);
$.each(arrThisPayreffee,function(i,n){
sumData = sumData + Number(convertStrPlanfeeToNumber(n.value));
});
--获取勾选中的对应的值
var billingCodes = "";
var checkboxId = $("input[id='checkboxId']");
$.each(checkboxId,function(i,n){
if($(this).attr("checked")){
var temp = $("input[id='billingCode']")[i];
billingCodes += temp.value+",";
}
});
$("input[name='prpjpolicyinvoiceVo.checkBoxName']").each(
function(index, domEle){ --多选框遍历,校验每一个选中的
if($(this).attr("checked")){
var policyValue = $("input[id='policyNo']")[index].value;
var endorseValue = $("input[id='endorseNo']")[index].value;
var transReferenceValue = $("input[id='transReference']")[index].value;
var businessNo = policyValue + "," + endorseValue + "," + transReferenceValue;
businessNoList += businessNo + "@";
}
})
function confirmDelete(){ --点击哪行的Button,就隐藏哪行
var checkbox = $("input[id='checkboxId']");
$.each(checkbox,function(i,n){
if($(this).attr("checked")){
$("#deleteOne"+i).parent().parent().hide();
}
});
}
根据name获取值 : name=\"list["+i+"]\"
var allMoney = 0; --在js中,遍历循环获取选中的所有的金额总和
var checkbox = $("input[id='checkboxId']");
var length =checkbox.length;
for(var i = 0; i < length ; i++){
if(checkbox[i].checked == true){
var money = $("input[name='list["+i+"]']").val(); // var money = document.getElementByName("list["+i+"]").value;
allMoney += Number(convertStrPlanfeeToNumber(money));
}
}
alert(allMoney);
10. if($("input[name='prpjpolicyinvoiceVo.checkBoxName']:checked").length == 0) {
alert("至少选择一条记录");
return false;
}
11. String s = window.prompt("请输入你的名字","");
var reason=window.prompt("请输入备注信息!","拒绝"); --reason是返回输入的字(默认先设为“拒绝”),可以通过输入的字判断下面业务逻辑
12. 确认框:
window.confirm(“一共100元,是否确定要买?”); --括号里面是确认框的提示符。确定继续执行代码,取消返回。
例如:
if(window.confirm("是否确认退回申请人?")){
window.location.href=contextRootPath+"/yqzl/pay_backToApplicant.do?billingCodes="+billingCodes;
}else{
for(var i=0; i<checkboxId.length;i++){
checkboxId[i].checked = false;
}
}
13. var paystart =$.trim($("#payamtstart").val());
var reg=/^([1-9][\d]{0,7}|0)(\.[\d]{1,2})?$/; --正则表达式在js中的用法,只能是两位小数点的数字类型
if(paystart!="" && !reg.test(paystart)){
alert("金额输入不合法");
return true;
}
28. $("#passFm").attr("action", "taskNodeApprove.do").submit(); --> 表单提交
29. <%@ include file="/pay/vatInvoice/invoiceApplyDetailEdit.jsp" %> --嵌套一个jsp页面
30. οnclick="javascript:document.location.href='${ctx}/pay/pay_preparePayQuery.do?opreateType=preparePayQuery&&${conditions }';"
31. $("input[name='inputTest']")[0].value
$("input[name='inputTest']").val()
32.
33. var checkboxId = $("input[id='checkboxId']"); --遍历所有的多选框,全部为未选中状态
for(var i=0; i<checkboxId.length;i++){
checkboxId[i].checked = false;
}
$("input[name='"+name+"']").attr("checked",true); --将指定名字的复选框全选/取消全选
34. function insertApplication1(){ --在table中增加一行
$("trId").clone(true).insertAfter(this); --trId: tr的id
}
function deleteRowForExpApply1(){ --在table中删除选中的行
$("input:checked").detach();
}
35.
<td class=\"inputcenter\"><<a href=\"javascript:prepareUpdate('"+obj.data[i]["comcode"]+"')\">修改</a>"; --在js中,点击A标签,触发js中的方法
<td class=\"inputcenter\"><a href=\"#\" οnclick=\"showDetail()\" >"+obj.data[i]["comcode"]+"</a>" ;
36. JSONObject jsonObject = new JSONObject(); --将后台的字符串传至前台js
jsonObject.put("msg", "删除成功");
HttpServletResponse response = getResponse();
response.setContentType("text/html;charset=UTF-8");
response.getWriter().write(jsonObject.toString());
response.getWriter().flush();
js接受: alert(eval("("+obj+")").msg);
37.
38. DecimalFormat df = new DecimalFormat("0.00000000000"); --转固定的BigDecimal格式,然后tostring
39. @org.junit.Test --测试Test,加在方法上,可以输出,代替main方法
40. Date date = new DateTime(DateTime.current(),DateTime.YEAR_TO_SECOND); --精确到时分秒的Date类型的时间格式
41. java中 : 字符串截取从0开始,左闭右开,从下标开始到下标为多少结束。String s ="123456"; String s1 = s.substring(3, 5); s1=45;
oracle中: 字符串截取从1开始,截取多少个 String s ="123456"; String s1 = substr(s,3,1); s1=3;
外部引入
<script language="javascript" src="${pageContext.request.contextPath}/ccs/ecexpapply/DateConfirm.js"></script>
<jsp:include page="../mywork/warnlimitlist.jsp"/>
<td style=\"word-break:break-all\" >" --自动换行,不加的话,控制width也行,但是翻页就不换行了
http://127.0.0.1:8080/payment == http://localhost:8080/payment
isNaN() 函数用于检查其参数是否是非数字值。
οnclick="javascript:history.go(-1);" />
history.back();
js中,Number类型的数据 toFixed(n);四舍五入保留n位小数
${fn:length(string1)}--JSTL返回集合或者string长度
<Context path="/costmcs" docBase="D:\\costmcs\\costmcs_8090\\costmcs" debug="0" reloadable="false"></Context> --config/service.xml最下面配置加载项目路径,启动项目
document.getElementById("p1").style.color="#ff0000"; --给标签加颜色
document.getElementById("p2").style.color="#ff0000"; --给标签加颜色
onclick ="window.location = $(this).parent().parent().parent().parent().attr('href')"; --在jsp中直接添加点击事件
window.location.href="http://qq.com";
private DecimalFormat df = new DecimalFormat("###,##0.00"); --#有则写,没有则不写 0.00代表保留两位小数
javaScript常用一些方法
最新推荐文章于 2021-03-19 09:24:29 发布