Create a webpage that will ask the user for a radius.
That number will be use to find the area of a circle with that radius, and then continue to calculate the next 9 circles with radii incrementing by one unit each time, and display the results to the page.
Then create a conditional statement that will limit the output to only even numbered radii.
Then a conditional statement that will limit the output to only radii divisible by 3.
And I have a code so far that looks like this:
Radius:<input type="text" name="radius" value=1><br>
<button type="button" onClick="calculate(radius.value)"> Get Next </button><br>
var pie = 3.14;
document.write("(" + rad + "+" + counter + ")" + "*" + "(" + rad + "+" + counter + ")" + "*" + pie + "=");
var area = ((parseInt(rad)+counter)*(parseFloat(rad)+counter))*(pie);
document.write(area + "<br>");
So far it's not working. I'm new to scripting, and I'm having trouble understanding what's wrong.
Do not use document.write which is made to write on the page during is opening but never when the document is closed (after the click, in your case).
Insert a div with, for example, an id="rsp" and replace your document.write by a
NB : See this page The <center> element is deprecated in HTML 4.01. Pi is given by Math.PI. Take care with radius.value and rad which are strings (counter+parseInt(rad) would be better)...