数组解决 单价:万
数量:
总价:元
<script><br />
function fx(){<br />
var s=document.getElementById('danjia[]').value;<br />
if(!s)return;<br />
s=parseInt(s);<br />
var c=document.getElementById('shuliang[]').value;<br />
c=parseInt(c);<br />
if(!c)return;<br />
document.getElementById('zongjia').innerHTML=Math.round(s*c)<br />
}<br />
</script>
我这个是数组,怎么让总价放到对应的总价td里
------解决方案-------------------- var s=document.getElementById('danjia[]').value;
应为
var s=document.getElementById('danjia').value;
var c=document.getElementById('shuliang[]').value;
应为
var c=document.getElementById('shuliang').value; ------解决方案-------------------- 你用的是getElementById();括号里应该写的是属性id,而不是用的getElementsByName(); ------解决方案--------------------
楼主不怎么喜欢用jquery的
如果喜欢用的话可以这样写 var zj;
zj=$('#danjia').val()*$('#shuliang').val();
$('#zongjia').text(zj);
希望回答对你有帮助
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn