<a href>中href获取参数的问题。 本帖最后由 w156445045 于 2012-05-03 16:52:25 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 web/athlete/athleteAdd.jsp?id=<bean:write property='unitGroupIdTest' /> 加上去怎么不行呢~<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean"%>Can not find the tag library descriptor for "http://struts.apache.org/tags-bean" 晕,<a href="javascript:onHref();" title="查看运动员" target="topFrame" >新增</a>function onHref(){ var _obj=document.getElementById('unitGroupIdTest'); if(_obj){ //这里改你自己要的提交方式 location.href/submit都行 windows.location.href='web/athlete/athleteAdd.jsp?id='+_obj.value; }} 解释一下:a 标签的href=不要直接写事件跳转,应该用 onclick做事件跳转,这样做可以避免页面没按我们想要的结果调转!<a href="javascript:void(0)" onclick="goto();" target='topFrame'>新增</a><script type="text/script"> function goto(){ var unitGroupIdTest=document.getElementById("unitGroupIdTest"); if(unitGroupIdTest){ windows.location.href="web/athlete/athleteAdd.jsp?id="+unitGroupIdTest.value; } }</script> <a href="javascript:void(0)" onclick="goto();" target='topFrame'>新增</a><script type="text/script"> function goto(){ var unitGroupIdTest=document.getElementById("unitGroupIdTest"); if(unitGroupIdTest){ windows.location.href="web/athlete/athleteAdd.jsp?id="+unitGroupIdTest.value; } }</script> 1、<input type="hidden" id="unitGroupIdTest" value="<s:property value="unitGroup.id" />"/> 你的这个隐藏域放在循环中,也是会有问题的。你的id,会一样的,你应该把id设置成动态的。2、你最好还是使用ls各位说的,用js提交,包括超级链接。 您好! <script > function goto(){ alert(123); var unitGroupIdTest=document.getElementById("unitGroupIdTest"); if(unitGroupIdTest){ windows.location.href="web/athlete/athleteAdd.jsp?id="+unitGroupIdTest.value; } }</script>为什么点了这个链接之后,只输出了123 而后面的缺不执行了呢,页面也没有跳转到新增的页面呢~ 你把隐藏域放在循环中,var unitGroupIdTest=document.getElementById("unitGroupIdTest");这句话肯定有问题,肯定有多个一样的id为unitGroupIdTest的 那我该怎么办呢,我页面上的那个连接就是想要获取这个循环中的值呢,其实这个循环中的这个值全部都是一样的呢~="<s:property value="unitGroup.id" /> 这个值 迭代出来的都是相同的请问咋做呢~ 这种方式我也用过,不过要点两次超链接,因为第一次点只是为href赋值,后来我也没想到什么方法了 在生成的时候可以这样<input type="hidden" id="unitGroupIdTest${(index)}" value="<s:property value="unitGroup.id" />"/>index取你循环的索引号,这样就有多个hidden,然后再用链接的时候这样写<a href="javascript:onHref(index);" title="查看运动员" target="topFrame" >新增</a>function onHref(_index){ var _obj=document.getElementById('unitGroupIdTest'+_index); if(_obj){ //这里改你自己要的提交方式 location.href/submit都行 windows.location.href='web/athlete/athleteAdd.jsp?id='+_obj.value; }} 这个问题已经解决了找了半天,其实也不是这个index的问题是windows.loation.href的问题 windows 多了个s正确是应该是window.loation.href哎。。还是火狐好!!! 循环中的id应该动态的,否则你js获取的永远都只是第一个id的数值 大家帮我看看这是什么异常 请教问题,linux 下 tomcat关闭时报错 struts页面跳转问题? 登录界面的错误 jdbc访问oracle function的问题 webwork的HelloWorld问题,高手请进! 关于访客浏览的问题?急急急急急*************给高分 请教:一个关于自定义标签库的问题(100分!)再线等! 密码保护! Selenium和Spring Cloud一起会报一个NoSuchMethodError怎么解决? 怎么样在myeclipse7.0中配置struts2.0 关于web的数据库设计,请给些建议谢谢。
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean"%>Can not find the tag library descriptor for "http://struts.apache.org/tags-bean"
<a href="javascript:onHref();" title="查看运动员" target="topFrame" >新增</a>function onHref(){
var _obj=document.getElementById('unitGroupIdTest');
if(_obj){
//这里改你自己要的提交方式 location.href/submit都行
windows.location.href='web/athlete/athleteAdd.jsp?id='+_obj.value;
}
}
function goto(){
var unitGroupIdTest=document.getElementById("unitGroupIdTest");
if(unitGroupIdTest){
windows.location.href="web/athlete/athleteAdd.jsp?id="+unitGroupIdTest.value;
}
}
</script>
function goto(){
var unitGroupIdTest=document.getElementById("unitGroupIdTest");
if(unitGroupIdTest){
windows.location.href="web/athlete/athleteAdd.jsp?id="+unitGroupIdTest.value;
}
}
</script>
2、你最好还是使用ls各位说的,用js提交,包括超级链接。
<script >
function goto(){
alert(123);
var unitGroupIdTest=document.getElementById("unitGroupIdTest");
if(unitGroupIdTest){
windows.location.href="web/athlete/athleteAdd.jsp?id="+unitGroupIdTest.value;
}
}
</script>为什么点了这个链接之后,只输出了123 而后面的缺不执行了呢,页面也没有跳转到新增的页面呢~
我页面上的那个连接就是想要获取这个循环中的值呢,其实这个循环中的这个值全部都是一样的呢~="<s:property value="unitGroup.id" /> 这个值 迭代出来的都是相同的请问咋做呢~
<input type="hidden" id="unitGroupIdTest${(index)}" value="<s:property value="unitGroup.id" />"/>
index取你循环的索引号,这样就有多个hidden,然后再用链接的时候这样写
<a href="javascript:onHref(index);" title="查看运动员" target="topFrame" >新增</a>function onHref(_index){
var _obj=document.getElementById('unitGroupIdTest'+_index);
if(_obj){
//这里改你自己要的提交方式 location.href/submit都行
windows.location.href='web/athlete/athleteAdd.jsp?id='+_obj.value;
}
}
的问题 windows 多了个s
正确是应该是window.loation.href哎。。还是火狐好!!!
循环中的id应该动态的,否则你js获取的永远都只是第一个id的数值