javascript参数传递问题
cell.innerHTML=<imgborder="0"src="../images/fo.gif"onclick="MM_openBrWindow('+materia...
cell.innerHTML =<img border="0" src="../images/fo.gif"onclick="MM_openBrWindow('+material_count.value+')">
上面代码是用javascript代码添加一图片,图片有onclick()事件,material_count.value 是变量,请问要传递material_count.value和字符串"material"因该怎么写
最后得到的代码应该是MM_openBrWindow('1','material')
弄了一上午没搞定,请大家帮帮忙,
坏蛋 - 经理 四级 不行啊 展开
上面代码是用javascript代码添加一图片,图片有onclick()事件,material_count.value 是变量,请问要传递material_count.value和字符串"material"因该怎么写
最后得到的代码应该是MM_openBrWindow('1','material')
弄了一上午没搞定,请大家帮帮忙,
坏蛋 - 经理 四级 不行啊 展开
2个回答
展开全部
<input type="text" name="material_count" id="material_count" size="45" value="试试">
<div id="cell"></div>
<script>
function MM_openBrWindow(a,b){
alert(a+"\n\n"+b);
}
var cell=document.getElementById('cell');
var material_count=document.getElementById('material_count');
cell.innerHTML='<img onclick=MM_openBrWindow("'+material_count.value+'","material") src="../images/fo.gif" border="0">';
alert(cell.innerHTML);
</script>
<div id="cell"></div>
<script>
function MM_openBrWindow(a,b){
alert(a+"\n\n"+b);
}
var cell=document.getElementById('cell');
var material_count=document.getElementById('material_count');
cell.innerHTML='<img onclick=MM_openBrWindow("'+material_count.value+'","material") src="../images/fo.gif" border="0">';
alert(cell.innerHTML);
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询