我是一个完全的新手,正在学习HTML和JavaScript。我正在制作一份逐步绘制Sri Chakra的指南,每个步骤都需要进行计算,我希望用户只需输入一个数字,就可以显示所有公式,就像答案一样。这些计算很简单,例如x/4=a,x/5=b,x/8=c,x*1.15=d。
然后当他们到达该步骤的不同页面时,我希望a或b或c或d出现。当他们第一次计算时,我希望数字以答案的形式出现。
这是我为一个页面准备的内容。
我的JS是calculator.js
function calculate(){
var mainradius=prompt ("What is the radius of the Main Circle?","");
var a=mainradius/4;
localStorage.setItem("fourth","a");
document.write(fourth + "<br />");
var b=mainradius/5;
var b= localStorage.setItem ("1/5","b");
var c=mainradius/8;
var c= localStorage.setItem ("1/8","c");
var d=mainradius*1.15;
var e=mainradius*1.25;
var f=mainradius*1.3;
var g=mainradius*1.35;
var h=mainradius*1.4;
var i=mainradius*1.45;
var j=mainradius*1.5;
}
the page that runs the calculator page 2 is
<html>
<head>
<title> Material and Calculator</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<script type="text/javascript" src="calculator.js">
</script>
<input type="number" onclick="calculate()" value="0">
<h1> Material and Calculator </h1>
<h3> Input the length of the Main Radius <br/>
<h3><form oninput="x.value=parseInt(mainradius.value)/4, y.value=parseInt(mainradius.value)/5, z.value=parseInt(mainradius.value)/8
, g.value=parseInt(mainradius.value)*1.15, h.value=parseInt(mainradius.value)*1.25, i.value=parseInt(mainradius.value)*1.3, j.value=parseInt(mainradius.value)*1.35,
k.value=parseInt(mainradius.value)*1.4,l.value=parseInt(mainradius.value)*1.45, m.value=parseInt(mainradius.value)*1.5">
<input type="number" id="mainradius" value="0">
=<output name="x" for="mainradius"></output> ( 1/4th ) <br>
=<output name="y" for="mainradius"></output> ( 1/5th ) <br>
=<output name="z" for="mainradius"></output> ( 1/8th ) <br>
=<output name="g" for="mainradius"></output> ( *1.15 ) <br>
=<output name="h" for="mainradius"></output> ( *1.25 ) <br>
=<output name="i" for="mainradius"></output> ( *1.3 ) <br>
=<output name="j" for="mainradius"></output> ( *1.35 ) <br>
=<output name="k" for="mainradius"></output> ( *1.4 ) <br>
=<output name="l" for="mainradius"></output> ( *1.45 ) <br>
=<output name="m" for="mainradius"></output> ( *1.5 ) <br>
</form>
<p> Reccomended using 4 or 5 </p>
</fieldset>
</form></h3>
<h1><a href="index.html"> Back </a>
<a href="3.html"> Next </a></h1>
</body>
</html>
and the page I want like the one fourth to come up in is page 5
<html>
<head>
<title> Step 3 a.</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<h1> Step 3a </h1>
<h2> Now Mark your line with 9 Marks, Labeled A-I </h2>
<h2> You will split the top half of the radius into 4 Sections </h2>
<h3> Label the Top of the Line A </h3>
<h3> 1/4th the radius from A Label B </h3>
<script type="text/javascript" src="calculator.js">
var fourth =parseInt(localStorage.getItem("fourth"));
document.write(fourth + "<br />");
</script>
<output type="number" value="fourth"> is 1/4th the radius </output>
<h3> 1/4th the radius from B Label C </h3>
<h3> 1/5th the radius from C Label D </h3>
<h2><img class="pic3" src="../gifs/4Marks.png" /> </h2>
<h2><img class="pic2" src="../gifs/3.gif"/> </h2>
<h1><a href="4.html"> Back </a>
<a href="6.html"> Next </a></h1>
</body>
</html>