<a href=caxh/down_execgyload?page=1&jgm='+choice1+'&sh='+choice2+'>查看数据</a> choice1和choice2是javascript中的变量,但是以上写法变量值传递不了,如何解决?谢谢大家!
<a href=caxh/down_execgyload?page=1&jgm='+choice1+'&sh='+choice2+'>查看数据</a> choice1和choice2是javascript中的变量,但是以上写法变量值传递不了,如何解决?谢谢大家!
<a href=“caxh/down_execgyload?page=1&jgm='+choice1+'&sh='+choice2+'”>查看数据</a>
var choice1 = "111";
var choice2 = "222";
</script>
方法一:修改a的href属性
<a id="aaa">查看数据</a>
<script type="text/javascript">
document.getElementById("aaa").href='caxh/down_execgyload?page=1&jgm='+choice1+'&sh='+choice2;
</script>
方法二:用document.write()
<script type="text/javascript">
document.write('<a href=caxh/down_execgyload?page=1&jgm='+choice1+'&sh='+choice2+'>查看数据</a>');
</script>
<input type="text" id="b">
<input type="button" id="btn" onclick="btnClick()" value="确定">
<input Type="Text" id="aaa" style="width:500px">
<script type="text/javascript">
function btnClick(){
var choice1 = document.getElementById("a").value;
var choice2 = document.getElementById("b").value;
document.getElementById("aaa").value='caxh/down_execgyload?page=1&jgm='+choice1+'&sh='+choice2;
}
</script>
没太看懂,不知道是不是你想要的
前两个input里输入内容,点确定按钮,最后一个input里输出你要的内容
<script type="text/javascript">
document.getElementById('button').onclick=function(){
location.href='http://'+location.host+'/caxh/down_execgyload? page=1&jgm='+choice1+'&sh='+choice2;
}
</script>至于根据参数值改变而刷新,具体还要看参数值是怎么变的~
<script type="text/javascript">
document.getElementById('button').onclick=function(){
location.href='http://'+location.host+'/caxh/down_execgyload? page=1&jgm='+choice1+'&sh='+choice2;
}
</script>至于根据参数值改变而刷新,具体还要看参数值是怎么变的~
我试了你的方法,提示是这样的: TypeError: document.getElementById(...) is null
<script type="text/javascript">
document.getElementById('button').onclick=function(){
location.href='http://'+location.host+'/caxh/down_execgyload? page=1&jgm='+choice1+'&sh='+choice2;
}
</script>至于根据参数值改变而刷新,具体还要看参数值是怎么变的~
我试了你的方法,提示是这样的: TypeError: document.getElementById(...) is null
如果是按照代码来,是不会出现这个错误的,贴下你的代码看看吧。