%macro showpage1( index, show, url );
%let url1 = &url;
filename _next url "&url";
data search_website;
infile _next length = len lrecl = 32767;
input text $varying32767. len;
if index(text, '<span>') or index(text, '</span>');
retain i;
if index(text, '<h2 class="title"') then i+1;
run;
data counting;
set search_website;
by i;
if first.i then count = 0;
count+1;
run;
proc transpose data=counting out=search_one_line prefix=info;
by i;
id count;
var text;
run;
data info1_&i (keep=var1 var 2 var3);
set dataset1;
run;
options missing=0;
%mend showpage1;
我希望代码获取输出,尝试计算尺寸权重(L x W x H / 5000),请一位有人帮助我吗?
输入长度,宽度,高度值后,我无法获得尺寸重量。
答案 0 :(得分:1)
您使用的是IsNumber(),它不是本机函数。试试这段代码
<html>
<head>
<script type="text/javascript">
function checkunit()
{
if(document.getElementById("unit2").value=="CK")
{
document.getElementById("unittype1").innerHTML='cm';
document.getElementById("unittype2").innerHTML='cm';
document.getElementById("unittype3").innerHTML='cm';
}
else
{
document.getElementById("unittype1").innerHTML='in';
document.getElementById("unittype2").innerHTML='in';
document.getElementById("unittype3").innerHTML='in';
}
}
function validatecal(form)
{
debugger;
if (form.vm_length.value==""
|| form.vm_length.value==0) {
alert('Enter Length');
form.vm_length.focus();
return false
}
if (isNaN(form.vm_length.value)
&& form.vm_length.value!="") {
alert('Invalid Length');
form.vm_length.focus();
return false
}
if (form.vm_width.value==""
|| form.vm_width.value==0) {
alert('Enter Width');
form.vm_width.focus();
return false
}
if (isNaN(form.vm_width.value)
&& form.vm_width.value!="") {
alert('Invalid Width');
form.vm_width.focus();
return false
}
if (form.vm_height.value==""
|| form.vm_height.value==0) {
alert('Enter Height');
form.vm_height.focus();
return false;
}
if (isNaN(form.vm_height.value)
&& form.vm_height.value!="") {
alert('Invalid Height');
form.vm_height.focus();
return false
}
calcVolWeight();
return false;
}
function calcVolWeight() {
var lengthValue = document.getElementById("vm_length").value;
var widthValue = document.getElementById("vm_width").value;
var heightValue = document.getElementById("vm_height").value;
var weightDivisor = document.getElementById("unit2").value == "IP" ? 139 : 5000;
var roundFactor = document.getElementById("unit2").value == "IP" ? 1 : 0.5;
var originalVolume = lengthValue * widthValue * heightValue;
// Calculate the volumetric weight
var calcVolWeight = roundFactor * Math.ceil(( originalVolume / weightDivisor ) / roundFactor);
document.getElementById("total_weight").value = parseFloat(calcVolWeight);
}
</script>
</head>
<body>
<form name="vcalculator" id="vcalculator" method="post" onSubmit="return validatecal(this)">
<label >Select Units :</label>
<select name="unit2" id="unit2" onChange="checkunit()" >
<option value="CK">CM/KG</option>
<option value="IP">Inches/Pounds</option>
</select>
</div>
</div>
<label >Enter Dimensions :</label>
<label>Length</label>
<input type="text" name="vm_length" id="vm_length" >
<span id="unittype1" >cm</span>
<label ">Width</label>
<input type="text" name="vm_width" id="vm_width" />
<span id="unittype2" >cm</span>
<label ">Height</label>
<input type="text" name="vm_height" id="vm_height" />
<span id="unittype3" >cm</span>
<label >Dimensional Weight :</label>
<input type="text"disabled="disabled"name="total_weight" id="total_weight" >
<input type="submit" value="Calculate" name="Submit"/>
<input type="reset" value="Clear" name="Submit2" />
</form>
</body>
</html>
&#13;