【发布时间】:2017-09-29 10:41:46
【问题描述】:
我为不久前编写的基本 HTML/CSS 页面创建了一个脚本,它在标准网站中运行良好,但当我尝试将其导入客户的新 Wordpress 网站时,该脚本无法运行。
新网站:http://www.fencingfabrication.com.au/quote-calculator/
HTML
*<h1>S & N Fencing</h1>
<h2>Get a fencing quote today</h2>
<h4>Requires browser Javascript</h4>
<h3>Gate dimenstions</h3>
Wood Look 10% extra<input type="checkbox" id="check1" value=false><br>
<p>Length in mm</p><input id="a" type="text"/>
<p>Width in mm</p><input id="b" type="text"/>
<br><br><br>
<input type="button" onclick="val()" value="Calculate Total"/>*
<script type="text/javascript">
var a,b; /*creates variables a and b*/
var gatePrice = 500; /*price per square meter of fencing*/
function setValues() /*assigns value of a and b using id*/
{
a = Number(document.getElementById("a").value);
b = Number(document.getElementById("b").value);
}
function check_tenpercent(checkbox) /*checks if check boxes are checked and adds assigns values to variable*/
{
var retval = 1;
if(checkbox.checked == true)
{
retval = 1.1;
}
return retval;
}
function val()
{
setValues();
var rate1 = check_tenpercent(document.getElementById("check1"));
gateMeters = a*b / 1000000;
gateMeters = gateMeters * rate1;
gateMeters = gateMeters * gatePrice;
result = gateMeters;
if(result >= 700){
alert("The total fencing price for this job is" + " $" + result.toFixed(2)); /*gives out total price of fencing*/
}else {
alert("This job would cost" + " $" + result.toFixed(2) + ". " + "Minimum price is $700");
}
}
</script>
【问题讨论】:
标签: javascript wordpress