一個(gè)運(yùn)費(fèi)模板的需求,類似淘寶的運(yùn)費(fèi)模板的設(shè)置,其中存在div定位在文本框下
<script src="${ctx}/scripts/BillionFun/common.js"></script>
<style>
input{
width:50px;
}
#t_location li{
list-style: none;
float:left;
width:24%;
}
#t_location{
width:400px;
border:1px green solid;
background-color:gray;
position: absolute;
display: none;
}
</style>
<c:choose>
<c:when test="${shipfeetem.chargeMode==1}">
<c:set var="chargeMode" value="個(gè)"></c:set>
</c:when>
<c:when test="${shipfeetem.chargeMode==2}">
<c:set var="chargeMode" value="元"></c:set>
</c:when>
</c:choose>
<table>
<tr>
<td>模板名稱:</td>
<td colspan="3">${shipfeetem.fullName }</td>
</tr>
<tr>
<td>計(jì)費(fèi)方式:</td>
<td>
<c:choose>
<c:when test="${shipfeetem.chargeMode==1 }">數(shù)量</c:when>
<c:when test="${shipfeetem.chargeMode==2 }">金額</c:when>
</c:choose>
</td>
<td>模板類型:</td>
<td>
<c:choose>
<c:when test="${shipfeetem.dispatch==1 }">按區(qū)域計(jì)費(fèi)</c:when>
<c:when test="${shipfeetem.dispatch==2 }">全國統(tǒng)一計(jì)費(fèi)</c:when>
</c:choose>
</td>
</tr>
</table>
<table>
<tr>
<td>免郵條件:</td>
<td> 買 <input type="text" id="t_freeCondition" name="" value="" /> ${chargeMode}(含)以上免郵,</td>
</tr>
<tr>
<td>至 <input type="text" name="t_provinces" value="" />的運(yùn)費(fèi):</td>
<td>
買 <input type="text" id="t_baseCondition" name="" value="" /> ${chargeMode}(含)以內(nèi),
收郵費(fèi)<input type="text" name="" id="t_basePrice" value="" /> 元,
每多買 <input type="text" id="t_addCondition" name="" value=""/> ${chargeMode}(含)以內(nèi),
加收郵費(fèi) <input type="text" id="t_addPrice" name="" value=""/> 元.
</td>
</tr>
<tr>
<td>至 <input type="text" name="t_provinces" value="" />的運(yùn)費(fèi):</td>
<td>
買 <input type="text" id="t_baseCondition" name="" value="" /> ${chargeMode}(含)以內(nèi),
收郵費(fèi)<input type="text" name="" id="t_basePrice" value="" /> 元,
每多買 <input type="text" id="t_addCondition" name="" value=""/> ${chargeMode}(含)以內(nèi),
加收郵費(fèi) <input type="text" id="t_addPrice" name="" value=""/> 元.
</td>
</tr>
<tr>
<td>至 <input type="text" name="t_provinces" value="" />的運(yùn)費(fèi):</td>
<td>
買 <input type="text" id="t_baseCondition" name="" value="" /> ${chargeMode}(含)以內(nèi),
收郵費(fèi)<input type="text" name="" id="t_basePrice" value="" /> 元,
每多買 <input type="text" id="t_addCondition" name="" value=""/> ${chargeMode}(含)以內(nèi),
加收郵費(fèi) <input type="text" id="t_addPrice" name="" value=""/> 元.
</td>
</tr>
</table>
<div id="t_location">
<c:forEach var="province" items="${list}">
<c:if test="${province.parentId==0}">
<li><input type="checkbox" value="${province}">${province.fullName }</li>
</c:if>
</c:forEach>
<br/>
<c:forEach var="province" items="${list}">
<c:if test="${province.parentId!=0}">
<li><input type="checkbox" value="${province}">${province.fullName }</li>
</c:if>
</c:forEach>
<div style="clear: both;"><a href="javascript:$('#t_location').hide();">關(guān)閉</a></div>
</div>
<script type="text/javascript">
$().ready(function(){
$("input[name='t_provinces']").click(function(){
// alert(this.clientWidth);
var pos=new getPos(this);
$("#t_location").attr("style",";top:"+(pos.Top+this.clientHeight+5)+"px;left:"+pos.Left+"px");
$("#t_location").show();
});
});
</script>
common.js里面的用到的方法主要是:
function getPos(obj){
this.Left=0;
this.Top=0;
this.Height=obj.offsetHeight;
this.Width=obj.offsetWidth;
var tempObj=obj;
while (tempObj.tagName.toLowerCase()!="body" && tempObj.tagName.toLowerCase()!="html"){
this.Left+=tempObj.offsetLeft;
this.Top+=tempObj.offsetTop;
tempObj=tempObj.offsetParent;
}
}
用
getPos(obj)這個(gè)方法得到元素在網(wǎng)頁中的絕對(duì)位置
用this.clientHeight得到元素的自身的高,如果需要用到寬,則是this.clientWidth 詳細(xì)請(qǐng)見
知人不必言盡,留三分余地于人,留些口德于己;
責(zé)人不必苛盡,留三分余地于人,留些肚量于己;
才能不必傲盡,留三分余地于人,留些內(nèi)涵于己;
鋒芒不必露盡,留三分余地于人,留些收斂于己;
有功不必邀盡,留三分余地于人,留些謙讓于己;得理不必?fù)尡M,留三分余地于人,留些寬容于己;
得寵不必恃盡,留三分余地于人,留些后路于己;
氣勢(shì)不必倚盡,留三分余地于人,留些厚道于己;
富貴不必享盡,留三分余地于人,留些福擇于己;
凡事不必做盡,留三分余地于人,留些余德于己。
N:
Q:412546724
E:yi.zhu89@yahoo.com.cn
M:13611084323