jsp同一页面如何从hidden里面取值并作为参数传递???
jsp代码如下:
<script type="text/javascript">
var tel=$("body").data('temp');
$('#tel_hidden').val(tel);
</script>
<input type="hidden" id="tel_hidden" value="" name="tel_hidden"/>
<ul class="treeFolder" >
<li><a href="javacript:;" ><s:text name="register_manage"/></a>
<ul>
<li><a herf="getByID.do?telnumber="+tel_hidden target="dialog" cc="true" rel="add" >welcome</a></li>
</ul>
</li>
</ul>
需求描述:怎么在<a herf>里面把tel_hidden的值传递过去?也就是把"getByID.do?telnumber="+tel_hidden里面的tel_hidden替换成<input type="hidden">的value?
------解决方案--------------------//重构了代码,实现了你的需求
<script type="text/javascript">
$(document).ready(function){
var tel=$("input[name='tel_hidden']").val();
var welcome=$("input[name='welcome']");
welcome.click(function(){
window.location="getByID.do?telnumber="+tel;
});
}
</script>
<input type="hidden" id="tel_hidden" value="" name="tel_hidden"/>
<ul class="treeFolder" >
<li><a href="javacript:;" ><s:text name="register_manage"/></a>
<ul>
<li><a herf="javascript:;" target="dialog" cc="true" rel="add" name="welcome" >welcome</a></li>
</ul>
</li>
</ul>
------解决方案--------------------
<head>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var a = $("#a").attr("herf") + $("#tel_hidden").val();
alert(a);
})
</script>
</head>
<body>
<input type="hidden" id="tel_hidden" value="sss" name="tel_hidden"/>
<ul>
<li><a id="a" herf="getByID.do?telnumber=" target="dialog" cc="true" rel="add" >welcome</a></li>
</ul>
</body>
------解决方案--------------------
function linkTo(){
alert(document.getElementById("tel_hidden").value);
window.location="getByID.do?telnumber="+document.getElementById("tel_hidden").value;
}
<a href="javascript:linkTo();">vvvv</a>
------解决方案--------------------<