今天有一个项目,ASP语言编写的,要实现不提交页面,依据输入的数据进行计算并显示其计算结果。反复调试一个下午+晚上终于完美解决。
一个是ASP文件,test.asp
一个是JS文件,CountFromInput.js
CountFromInput.js 代码如下
// 不提交页面依据输入的数据计算结果,多行
// window.['变量名称'+动态变量] 此为全局变量。
function jsresult(n,xiaoshuwei){
window['jsabpemtype'+n]=document.getElementById("jsabpemtype"+n);
window['jsabsdprice'+n]=document.getElementById("jsabsdprice"+n);
window['jsabpeL'+n]=document.getElementById("jsabpeL"+n);
window['jsabpeW'+n]=document.getElementById("jsabpeW"+n);
window['jsabpeH'+n]=document.getElementById("jsabpeH"+n);
window['jsabpesizeunit'+n]=document.getElementById("jsabpesizeunit"+n);
window['jsabpeprice'+n]=document.getElementById("jsabpeprice"+n);
if('oninput' in window['jsabsdprice'+n]){
window['jsabpemtype'+n].addEventListener("input",getWord,false);
window['jsabsdprice'+n].addEventListener("input",getWord,false);
window['jsabpeL'+n].addEventListener("input",getWord,fal