1. 程式人生 > >前端彙總----Jsp 標籤--forEach、choose、when、otherwise、fmt、if 包括 ajax、jQuery 等各種操作彙總《來自於英科》

前端彙總----Jsp 標籤--forEach、choose、when、otherwise、fmt、if 包括 ajax、jQuery 等各種操作彙總《來自於英科》

jQuery

1.獲取 下拉框的選中的value

<select title="還款型別" name="repaymentType" id="repaymentType">
			<c:forEach items="${ALL_REPAY_TYPE}" var="type">
					<option value="${type.key}">${type.value}</option>
			</c:forEach>
</select>



<!-- jQuery 獲取: -->
var checkType=$("#repaymentType option:selected").val();

 

2.html textarea 標籤使用

<textarea title="備註" name="remark" rows="5" cols="60" maxlength="50">${backUser.remark }</textarea>

3.函式互相呼叫

<script type="text/javascript">
	function submitFrm(){
		var checkType=$("#repaymentType option:selected").val();
		var checkNum=$("#orderId").val();	
		var trueRepaymentMoney = parseFloat($("#trueRepaymentMoney").val());
		
		if(trueRepaymentMoney <= 0){
			alertMsg.error('請輸入有效的還款金額!');
			return false;
		}else if((checkType=='2'&&checkNum.length!=15)||(checkType=='3'&&checkNum.length!=15)){
			//富有和連連15位訂單號
				alertMsg.error('請輸入正確的訂單號!');
				return false;
		}
		subRepay(trueRepaymentMoney); <!------------ 開始函式呼叫 --------------->
	}
	
	<!---------------------  被呼叫函式  --------------------------->
	function subRepay(trueRepaymentMoney){
		if(parseFloat("${remainMoney}") < trueRepaymentMoney){
			if(confirm('還款金額大於剩餘待還金額,確定繼續操作還款?')){
				$("#frm").submit();
				return;
			}else{
				return false;
			}
		}
		$("#frm").submit();
	}
	
</script>

1.c:if 標籤

​
<table class="searchContent">
	<tr>
		<td>資金型別: 
			<select name="repayChannel"  id="repayChannel">
			    <option value="">全部</option>
	                    <option <c:if test="${params.repayChannel eq 1}">selected="selected"</c:if> value="1" name="repayChannel" value="${params.repayChannel }">本息</option>
			    <option <c:if test="${params.repayChannel eq 2}">selected="selected"</c:if> value="2" name="repayChannel" value="${params.repayChannel }">補利息</option>
			    <option <c:if test="${params.repayChannel eq 3}">selected="selected"</c:if> value="3" name="repayChannel" value="${params.repayChannel }">本金</option>
			</select>
		</td>
	</tr>
</table>

​<td align="center">
		<c:if test="${rec.repayKoudaiType==0}">待處理</c:if>
		<c:if test="${rec.repayKoudaiType==1}">待還</c:if>
		<c:if test="${rec.repayKoudaiType==2}">正常還款</c:if>
		<c:if test="${rec.repayKoudaiType==3}">擔保戶墊付</c:if>
		<c:if test="${rec.repayKoudaiType==4}">擔保戶墊付待還</c:if>
		<c:if test="${rec.repayKoudaiType==5}">問題還款</c:if>
		<c:if test="${rec.repayKoudaiType==6}">異常訂單</c:if>
</td>

2.forEach、choose、when、otherwise、fmt

<c:forEach var="borrow" items="${pm.items }" varStatus="status" >
                    <tr>
                        <td align="center">${borrow.lateday}</td>
                        <td align="center"><fmt:formatDate value="${borrow.orderTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                        <td align="center">
                            <c:choose>
                                <c:when test="${ null != borrow.repaytime }">
                                    <fmt:formatDate value="${borrow.repaytime }" pattern="yyyy-MM-dd HH:mm:ss"/>
                                </c:when>
                                <c:otherwise>
                                    ---
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td align="center">
                            <c:choose>
                                <c:when test="${null != borrow.repayrtime}">
                                    <fmt:formatDate value="${borrow.repayrtime }" pattern="yyyy-MM-dd HH:mm:ss"/>
                                </c:when>
                                <c:otherwise>
                                    ---
                                </c:otherwise>
                            </c:choose>
                        </td>
                        <td align="center"> ${statusMap[borrow.status] }</td>
                    </tr>
                </c:forEach>