苹果:<INPUT onpropertychange=ch() value="3.0" type=text name=a> 数量:<INPUT onpropertychange=ch() value="2" type=text name=c><br>
香蕉:<INPUT onpropertychange=ch() value="2.0" type=text name=b> 数量:<INPUT onpropertychange=ch() value="2" type=text name=d><br>
总价:<INPUT value="0" type=text name=e>
<script language="JavaScript">
ch();
function ch(name)
{
document.getElementsByTagName("input").e.value=parseInt(document.getElementsByTagName("input").a.value)*parseInt(document.getElementsByTagName("input").c.value)+parseInt(document.getElementsByTagName("input").b.value)*parseInt(document.getElementsByTagName("input").d.value)
}
</script>
香蕉:<INPUT onpropertychange=ch() value="2.0" type=text name=b> 数量:<INPUT onpropertychange=ch() value="2" type=text name=d><br>
总价:<INPUT value="0" type=text name=e>
<script language="JavaScript">
ch();
function ch(name)
{
document.getElementsByTagName("input").e.value=parseInt(document.getElementsByTagName("input").a.value)*parseInt(document.getElementsByTagName("input").c.value)+parseInt(document.getElementsByTagName("input").b.value)*parseInt(document.getElementsByTagName("input").d.value)
}
</script>