私は1つのページにフォームを介してデータを収集し、そのデータを次のページに転送してJS機能で使用しようとしています。 (具体的には、二次方程式のA、B、Cの値を入力し、スクリプトがそれらの値を受け取り、方程式+答えを出力するページに送信します)。フォームを使用してJavascript関数のデータを収集しますか?
ここで--->ここ
<body>
<h1> Welcome to the Math Equation Solver </h1>
<p> Which equation would you like to solve? (Simply input the data for the equation you wish to solve). </p>
<form name="quad" method="get" action="JS_B.html">
<input
<input type="text" name="a_val" size="5">
<br>
<input type="text" name="b_val" size="5">
<br>
<input type="text" name="c_val" size="5">
<br>
<input type="submit" method="get" action="JS_B.html" value="Submit">
<input type="hidden" name="a_val">
<input type="hidden" name="b_val">
<input type="hidden" name="c_val">
</form>
だからとにかく私の2ページ目のコード--->
<title>JS_Math Scripts</title>
<body>
<script type="Javascript">
function answer()
{
var a = a_val
document.writeln(a_val)
var b = b_val
var c = c_val
var root = Math.pow(b, 2) - 4 * a * c
var answer1 = (-b + Math.sqrt(root))/2*a
var answer2 = (-b - Math.sqrt(root))/2*a
if(root<'0');
{
alert('This equation has no real solution.')
}else{
if(root=='0')
{
answerOne = answer1
document.writeln(answerOne)
answerTwo = 'No Second Answer'
}else{
answerOne = answer1
document.writeln(answerOne)
answerTwo = answer2
document.writeln(answerTwo)
}
}
}
// End -->
</script>
<input type="hidden" name="a_val">
<input type="hidden" name="b_val">
<input type="hidden" name="c_val">
<input type="hidden" name="answerOne">
<input type="hidden" name="answerTwo">
<input type="hidden" name="Answer">
</body>
</html>
で、AのためのI入力値の私の最初のページのコード、B、Cは2番目のページに移動しますが、結果は得られません。私はinspect要素を試してみましたが、コンソールにはエラーがないので、データが正しく転送されていると思います。何か案は?
結果0次
;
を削除(root))/ 2 * a; '、 ' var answer2 =(-b-Math.sqrt(root))/ 2 * a' 'var answer1 =(-b + Math.sqrt(root) – guest271314[JavaScriptでクエリ文字列値を取得する方法は?](http://stackoverflow.com/questions/901115/how-can-i-get-query-values-in-javascript) – colonelclick