如何使用下拉菜单更改数据?

时间:2016-04-09 02:51:27

标签: javascript math



// Can anyone please add coding so when level 2 is selected, the numbers in the equation get bigger. The part with selecting level 2 is messing me up // 


var num1 = [];
var num2 = [];
var ans = [];
var msum = [];
function INlist(count)
{
   document.getElementById("demo6").innerHTML = ""
   for (i = 0; i < count; i++)
   {
      num1[i] = 0;
      num2[i] = 0;
      ans[i] = 0;
      msum[i] = 0;
   }

   for (i = 0; i < count; i++)
   {
      num1[i] = Math.ceil(Math.random()*9); // these two lines decide how large the numbers are
      num2[i] = Math.ceil(Math.random()*9); 
      ans[i] = num1[i] + num2[i];

      msum[i] = num1[i] + " + " + num2[i] + " = "
      + "<input id=\"resp" + i + "\" onchange=\"check(this.value)\"    type=\"text\" name=\"fname\"><br>";

      document.getElementById("demo6").innerHTML = document.getElementById  ("demo6").innerHTML + msum[i];
   }
}
&#13;
<select id="mySelect">
<option id="Level1">Level 1</option> // selecting level 2 should make the equations harder 
<option id="Level2">Level 2</option>

</select>

<p id="demo"></p>

<button onclick="INlist(10)">Start!</button>
<p id="demo6"></p>
&#13;
&#13;
&#13;

0 个答案:

没有答案