Page 283 - Web Applications (803) Class 12
P. 283

}

                              var answer = document.getElementById(“Result”);

                               answer.textContent = “The array is “ + num + “\nSum of numbers in the
                                array: “ + sum;
                          }

                          calculateSum();

                      });   //close brackets of event listener function
                       Output:


























                   16.   Create a webpage which accepts the radius of a circle and choice from the user. Using the switch case in JavaScript
                      calculate and display the area or circumference of the circle as per choice entered.

                  Ans.  <html>
                      <head>

                          <title>Circle Calculator</title>
                      </head>
                      <body>

                          <h1>Circle Calculator</h1>
                          <label for=”radius”>Enter the radius of the circle:</label>
                          <input type=”number” id=”radius”>

                          <br> <br>
                          <label for=”calculation”>Choose what you want to calculate:</label>
                          <select id=”calculation”>

                              <option value=”area”>Area</option>
                              <option value=”circumference”>Circumference</option>

                          </select>
                          <button onclick=”calculate()”>Calculate</button>



                                                                                                    Practical Work   281
   278   279   280   281   282   283   284   285   286   287   288