日期:2014-05-16  浏览次数:20434 次

将参数带入网页

for(condition)
{
   echo '<a type="button" class="print" onclick="showprint(this)添加部分;" target="_blank">打印</a>';
}

<script language = "javascript">
function showprint(obj){
obj.removeAttribute("href");
obj.onclick=null;
obj.style.textDecoration= 'none ';
window.open("a.php?url=","_blank");
}
</script>


因为页面是带参数的,且在for循环中。如果是js中带参数的话就无法起到for循环的作用,如何修改才能使其带入指定参数?

------解决方案--------------------


for(condition)
{
   echo '<a type="button" class="print" onclick="showprint(this,\''.$id.'\')添加部分;" target="_blank">打印</a>';
}

<script language = "javascript">
function showprint(obj,id){
obj.removeAttribute("href");
obj.onclick=null;
obj.style.textDecoration= 'none ';
window.open("a.php?url="+id,"_blank");
}
</script>