<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>
------解决方案--------------------
<script type="text/javascript">
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>
------解决方案--------------------
+1
------解决方案--------------------
<input type="text" id="a">
<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;