Hey there CodingForums!
I hope the subject of this post was ok

(I read that you are having some problems with alot of strange subjects)
What i am trying to do is the following:
I read a tutorial on objects and thought i would try it out. The tutorial taught me how to make a function calculating the areal and circumspherence of the circle where the user input would be the radius.
To sum up: I want to make it possible for the user to write, say, "2" in the form text field and click "Calculate" and then the text will appear w/o reloading the page. I could easily do this by removing the objects but as i am training my object skills i would like to know if it is possible to do this with objects?
The problem is that i dont know how to take the user input. I know that in PHP it is "$_POST["name"]" but what is it in JS? And is it possible to jump into PHP and use $_POST inside the JS script or how can this be done?
This is my code so far (It prolly looks strange but i really dont know how to get it to work).
Code:
<script type="text/javascript">
function Circle(radius){
this.radius = radius;
this.getArea = function(){
return (this.radius*this.radius*3.14);
}
this.getOmkreds = function(){
var diameter = this.radius*2;
var omkreds = diameter*3.14;
return omkreds;
}
}
var bigCircle = new Circle(100);
document.write("The areal of your circle is: "+bigCircle.getArea()+"<br>");
document.write("The circumsference of your circle is: "+bigCircle.getOmkreds()+"<br>");
</script>
<form name="input" method="POST">
<input type="text" name="radius" />
<input type="button" value="Calculate" />
</form>
As you can see i have a predefined object: bigCircle. What i want to do is change the
new Circle(100) to
new Circle(USER INPUT HERE).
Does any of this make sense and is it even possible?
- BZeiler