/    Sign up×
Community /Pin to ProfileBookmark

Area and parimeter code help :(

what am i doing wrong ??? Guys can you please help?
THe laytout is correct but i cant get the results in the area and parimeter field.PLEASE

<html>
<head>
<title>Rectangle Calculator</title>
<script type=”text/javascript”>
function calcArea(1,w){
var area= 1*w
}
function calcPerim(1,w) {
var perimeter = 2*
(l+w)
}
function calc(f){
var width = parseFloat(widthBox)
var length = parseFloat(lengthBox)
area= calcArea (length.value, width.value)
areaBox.value = area
perimeterBox.value = calcPerim(length.value,width.value)
}
</script>
</head>
<body>
<p><strong>Area and Perimeter Calculator</strong></p>
<form id=”calcForm”>
Enter the width of the rectangle:
<input type=”text” name “lengthBox” size=”6″ /> <br/>
Enter the length of the rectangle:
<input type =”text”name=”lengthBox” size=”6″/>
<p><input type= “button” name=”calcBtn” value=”Calculate”
onclick=”calc(document.calculatorForm)”/></p>
The area is:<input type=”text” name=”perimeterBox” size=”12″/>
</form>
</body>
</html>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangNov 26.2005 — Nearly everything; compare this with your code:&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;title&gt;Rectangle Calculator&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt;
&lt;script type="text/javascript"&gt;
function calcArea(L,W){
return L*W;
}
function calcPerim(L,W) {
return 2*(L+W);
}
function calc(f){
var width = parseFloat(f.widthBox.value);
var length = parseFloat(f.lengthBox.value);
var area= calcArea (length, width);
f.areaBox.value = area;
f.perimeterBox.value = calcPerim(length,width);
}
&lt;/script&gt;
&lt;style type="text/css"&gt;
label {display:block;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;&lt;strong&gt;Area and Perimeter Calculator&lt;/strong&gt;&lt;/p&gt;
&lt;form name="calculatorForm" action="#"&gt;
&lt;div&gt;
&lt;label&gt;Enter the width of the rectangle: &lt;input type="text" name="widthBox" size="6"&gt;&lt;/label&gt;
&lt;label&gt;Enter the length of the rectangle: &lt;input type ="text"name="lengthBox" size="6"&gt;&lt;/label&gt;
&lt;p&gt;&lt;input type= "button" name="calcBtn" value="Calculate" onclick="calc(document.calculatorForm)"&gt;&lt;/p&gt;
&lt;label&gt;The area is: &lt;input type="text" name="areaBox" size="12"&gt;&lt;/label&gt;
&lt;label&gt;The perimeter is: &lt;input type="text" name="perimeterBox" size="12"&gt;&lt;/label&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@gina4unccauthorNov 28.2005 — Thats great....i really enjoy the help Fang ?
×

Success!

Help @gina4uncc spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...