这个JS怎么放到单独的JS文件中?
<scripttype="text/javascript">functionresetForm(){varinForm=document.inputs;varoutFor...
<script type="text/javascript">
function resetForm()
{
var inForm=document.inputs;
var outForm=document.outputs;
inForm.rolllength.value = 10.0;
outForm.cutlength.value = "";
inputs.rolllength.disabled = true;
inputs.rollwidth.focus();
inForm.patternrepeat.focus();
}
function sgn(v)
{
if (v > 0) return 1;
else if (v < 0) return -1;
else return 0;
}
function roundNum(value, precision)
//
{
var sign = sgn(value);
var adjust=0;
if ((value !=0) && (Math.abs(value) < 1)) {
adjust=sign;
value += adjust;
}
else
result += whole;
return result;
}
function validatePrompt (ctrl, prompt)
{
alert (prompt);
ctrl.focus();
ctrl.select();
return;
}
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 46 || charCode > 57))
return false;
return true;
}
function validateForm ( rolllength, rollwidth, patternrepeat, wallheight, wallwidth, trimlength)
{
// 验证纸卷长
if (rolllength.value.length==0)
{
validatePrompt (rolllength, "纸卷长必需输入.");
return false;
}
return true;
}
function calc()
{
var inForm=document.inputs;
var outForm=document.outputs;
// 验证所有五个所需的输入
if (!validateForm(inForm.rolllength, inForm.rollwidth, inForm.patternrepeat, inForm.wallheight, inForm.wallwidth, inForm.trimlength)) return;
// 处理输入的值
var pr1=((inForm.wallheight.value*1000)+ (inForm.trimlength.value*10))/(inForm.patternrepeat.value*10) ;
var pr2=Math.ceil(pr1)
var pr3=pr2*(inForm.patternrepeat.value)/100 ;
var pr4=roundNum(pr3,2);
outForm.cutlength.value=pr4;
var cl1=inForm.wallwidth.value/inForm.rollwidth.value;
var cl2=Math.ceil(cl1);
outForm.nocutlengths.value=cl2;
var nor1=cl2*pr4;
var nor2=nor1/inForm.rolllength.value;
var nor3=Math.ceil(nor2)
outForm.rollsrequired.value=nor3;
}
</script> 展开
function resetForm()
{
var inForm=document.inputs;
var outForm=document.outputs;
inForm.rolllength.value = 10.0;
outForm.cutlength.value = "";
inputs.rolllength.disabled = true;
inputs.rollwidth.focus();
inForm.patternrepeat.focus();
}
function sgn(v)
{
if (v > 0) return 1;
else if (v < 0) return -1;
else return 0;
}
function roundNum(value, precision)
//
{
var sign = sgn(value);
var adjust=0;
if ((value !=0) && (Math.abs(value) < 1)) {
adjust=sign;
value += adjust;
}
else
result += whole;
return result;
}
function validatePrompt (ctrl, prompt)
{
alert (prompt);
ctrl.focus();
ctrl.select();
return;
}
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 46 || charCode > 57))
return false;
return true;
}
function validateForm ( rolllength, rollwidth, patternrepeat, wallheight, wallwidth, trimlength)
{
// 验证纸卷长
if (rolllength.value.length==0)
{
validatePrompt (rolllength, "纸卷长必需输入.");
return false;
}
return true;
}
function calc()
{
var inForm=document.inputs;
var outForm=document.outputs;
// 验证所有五个所需的输入
if (!validateForm(inForm.rolllength, inForm.rollwidth, inForm.patternrepeat, inForm.wallheight, inForm.wallwidth, inForm.trimlength)) return;
// 处理输入的值
var pr1=((inForm.wallheight.value*1000)+ (inForm.trimlength.value*10))/(inForm.patternrepeat.value*10) ;
var pr2=Math.ceil(pr1)
var pr3=pr2*(inForm.patternrepeat.value)/100 ;
var pr4=roundNum(pr3,2);
outForm.cutlength.value=pr4;
var cl1=inForm.wallwidth.value/inForm.rollwidth.value;
var cl2=Math.ceil(cl1);
outForm.nocutlengths.value=cl2;
var nor1=cl2*pr4;
var nor2=nor1/inForm.rolllength.value;
var nor3=Math.ceil(nor2)
outForm.rollsrequired.value=nor3;
}
</script> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询