/    Sign up×
Community /Pin to ProfileBookmark

javascript to dreamweaver problem

ok.. so i got a piece of good workin code, which i had help with on this forum. i have used and trested it and works fine rite.. but as soon as i put it into dreamweaver it stops working: the two sets of code are.. i apologise for the amount of lines i have posted:

[CODE] <html>
<head>
<title>room square meter Calculator</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<script type=”text/javascript”>

function calcArea(L,W)
{return L*W;}

function calc(f,W,L){
var width = parseFloat(W);
var length = parseFloat(L);
var area = calcArea (length,width);
//var squaremeter = calcSquaremeter();

f.value = calcArea(length,width);
//f.squaremeterBox.value = squaremeter;}
}
</script>

<style type=”text/css”>
label {display:block;}
</style>
</head>
<body>

<p><strong>Wall coverage calculator</strong></p>
<form name=”calculatorForm” action=”#”>
<div>

<p><strong>Wall 1</strong></p>
<label>Width of wall 1: <input type=”text” name=”widthBox1″ size=”6″></label>
<label>Length of wall 1: <input type =”text” name=”lengthBox1″ size=”6″></label>

<p><input type= “button” name=”calcBtn” value=”Calculate”

onclick=”calc(this.form.areaBox1,this.form.widthBox1.value,this.form.lengthBox1.value)”></p>
<label>The area is: <input type=”text” name=”areaBox1″ size=”12″ readonly></label>

<p><strong>Wall 2</strong></p>
<label>Width of wall 2: <input type=”text” name=”widthBox2″ size=”6″></label>
<label>Length of wall 2: <input type =”text” name=”lengthBox2″ size=”6″></label>

<p><input type= “button” name=”calcBtn2″ value=”Calculate”

onclick=”calc(this.form.areaBox2,this.form.widthBox2.value,this.form.lengthBox2.value)”></p>
<label>The area is: <input type=”text” name=”areaBox2″ size=”12″ readonly></label>

<p><strong>Wall 3</strong></p>
<label>Width of wall 3: <input type=”text” name=”widthBox3″ size=”6″></label>
<label>Length of wall 3: <input type =”text” name=”lengthBox3″ size=”6″></label>

<p><input type= “button” name=”calcBtn3″ value=”Calculate”

onclick=”calc(this.form.areaBox3,this.form.widthBox3.value,this.form.lengthBox3.value)”></p>
<label>The area is: <input type=”text” name=”areaBox3″ size=”12″ readonly></label>

<p><strong>Wall 4</strong></p>
<label>Width of wall 4: <input type=”text” name=”widthBox4″ size=”6″></label>
<label>Length of wall 4: <input type =”text” name=”lengthBox4″ size=”6″></label>

<p><input type= “button” name=”calcBtn4″ value=”Calculate”

onclick=”calc(this.form.areaBox4,this.form.widthBox4.value,this.form.lengthBox4.value)”></p>
<label>The area is: <input type=”text” name=”areaBox4″ size=”12″ readonly></label>

<p><strong>Wall 5</strong></p>
<label>Width of wall 5: <input type=”text” name=”widthBox5″ size=”6″></label>
<label>Length of wall 5: <input type =”text” name=”lengthBox5″ size=”6″></label>

<p><input type= “button” name=”calcBtn5″ value=”Calculate”

onclick=”calc(this.form.areaBox5,this.form.widthBox5.value,this.form.lengthBox5.value)”></p>
<label>The area is: <input type=”text” name=”areaBox5″ size=”12″ readonly></label>

<p><strong>Wall 6</strong></p>
<label>Width of wall 6: <input type=”text” name=”widthBox6″ size=”6″></label>
<label>Length of wall 6: <input type =”text” name=”lengthBox6″ size=”6″></label>

<p><input type= “button” name=”calcBtn6″ value=”Calculate”

onclick=”calc(this.form.areaBox6,this.form.widthBox6.value,this.form.lengthBox6.value)”></p>
<label>The area is: <input type=”text” name=”areaBox6″ size=”12″ readonly></label>

<p><strong>Wall 7</strong></p>
<label>Width of wall 7: <input type=”text” name=”widthBox7″ size=”6″></label>
<label>Length of wall 7: <input type =”text” name=”lengthBox7″ size=”6″></label>

<p><input type= “button” name=”calcBtn7″ value=”Calculate”

onclick=”calc(this.form.areaBox7,this.form.widthBox7.value,this.form.lengthBox7.value)”></p>
<label>The area is: <input type=”text” name=”areaBox7″ size=”12″ readonly></label>

<p><strong>Wall 8</strong></p>
<label>Width of wall 8: <input type=”text” name=”widthBox8″ size=”6″></label>
<label>Length of wall 8: <input type =”text” name=”lengthBox8″ size=”6″></label>

<p><input type= “button” name=”calcBtn8″ value=”Calculate”

onclick=”calc(this.form.areaBox8,this.form.widthBox8.value,this.form.lengthBox8.value)”></p>
<label>The area is: <input type=”text” name=”areaBox8″ size=”12″ readonly></label>
</div>
</form>
</body>
</html> [/CODE]

the dreaver code is as folows :

[CODE]<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Al-Murads ceramic Tiles simulator</title>
<script type=”text/javascript”>
function calcArea(L,W)
{return L*W;}

function calc(f,W,L){
var width = parseFloat(W);
var length = parseFloat(L);
var area = calcArea (length,width);
//var squaremeter = calcSquaremeter();

f.value = calcArea(length,width);
//f.squaremeterBox.value = squaremeter;
}
}
</script>

<style type=”text/css”>
label {display:block;}
</style>
</head>

<body>
<table width=”715″ height=”100″ border=”1″>
<tr>
<td width=”705″><img src=”al-murad logo.JPG” width=”705″ height=”101″ /></td>
</tr>
</table>
<table width=”715″ height=”400″ border=”2″ cellpadding=”1″>
<tr>
<td width=”329″ height=”217″><p><strong>Wall 1</strong></p>
<label>Width of wall 1: <input type=”text” name=”widthBox1″ size=”6″></label>
<label>Length of wall 1: <input type =”text” name=”lengthBox1″ size=”6″></label>

<p><input type= “button” name=”calcBtn” value=”Calculate”

onclick=”calc(this.form.areaBox1,this.form.widthBox1.value,this.form.lengthBox1.value)”></p>
<label>The area is: <input type=”text” name=”areaBox1″ size=”12″ readonly></label>
&nbsp;</td>
<td width=”368″><p><strong>Wall 2</strong></p>
<label>Width of wall 2: <input type=”text” name=”widthBox2″ size=”6″></label>
<label>Length of wall 2: <input type =”text” name=”lengthBox2″ size=”6″></label>

<p><input type= “button” name=”calcBtn2″ value=”Calculate”

onclick=”calc(this.form.areaBox2,this.form.widthBox2.value,this.form.lengthBox2.value)”></p>
<label>The area is: <input type=”text” name=”areaBox2″ size=”12″ readonly></label>&nbsp;</td>

</tr>
<tr>
<td><p><strong>Wall 3</strong></p>
<label>Width of wall 3: <input type=”text” name=”widthBox3″ size=”6″></label>
<label>Length of wall 3: <input type =”text” name=”lengthBox3″ size=”6″></label>

<p><input type= “button” name=”calcBtn3″ value=”Calculate”

onclick=”calc(this.form.areaBox3,this.form.widthBox3.value,this.form.lengthBox3.value)”></p>
<label>The area is: <input type=”text” name=”areaBox3″ size=”12″ readonly></label>
&nbsp;</td>
<td><p><strong>Wall 4</strong></p>
<label>Width of wall 4: <input type=”text” name=”widthBox4″ size=”6″></label>
<label>Length of wall 4: <input type =”text” name=”lengthBox4″ size=”6″></label>

<p><input type= “button” name=”calcBtn4″ value=”Calculate”

onclick=”calc(this.form.areaBox4,this.form.widthBox4.value,this.form.lengthBox4.value)”></p>
<label>The area is: <input type=”text” name=”areaBox4″ size=”12″ readonly></label>
&nbsp;</td>
</tr>
<tr>
<td><p><strong>Wall 5</strong></p>
<label>Width of wall 5: <input type=”text” name=”widthBox5″ size=”6″></label>
<label>Length of wall 5: <input type =”text” name=”lengthBox5″ size=”6″></label>

<p><input type= “button” name=”calcBtn5″ value=”Calculate”

onclick=”calc(this.form.areaBox5,this.form.widthBox5.value,this.form.lengthBox5.value)”></p>
<label>The area is: <input type=”text” name=”areaBox5″ size=”12″ readonly></label>
&nbsp;</td>
<td><p><strong>Wall 6</strong></p>
<label>Width of wall 6: <input type=”text” name=”widthBox6″ size=”6″></label>
<label>Length of wall 6: <input type =”text” name=”lengthBox6″ size=”6″></label>

<p><input type= “button” name=”calcBtn6″ value=”Calculate”

onclick=”calc(this.form.areaBox6,this.form.widthBox6.value,this.form.lengthBox6.value)”></p>
<label>The area is: <input type=”text” name=”areaBox6″ size=”12″ readonly></label>
&nbsp;</td>
</tr>
<tr>
<td><p><strong>Wall 7</strong></p>
<label>Width of wall 7: <input type=”text” name=”widthBox7″ size=”6″></label>
<label>Length of wall 7: <input type =”text” name=”lengthBox7″ size=”6″></label>

<p><input type= “button” name=”calcBtn7″ value=”Calculate”

onclick=”calc(this.form.areaBox7,this.form.widthBox7.value,this.form.lengthBox7.value)”></p>
<label>The area is: <input type=”text” name=”areaBox7″ size=”12″ readonly></label>
&nbsp;</td>
<td><p><strong>Wall 8</strong></p>
<label>Width of wall 8: <input type=”text” name=”widthBox8″ size=”6″></label>
<label>Length of wall 8: <input type =”text” name=”lengthBox8″ size=”6″></label>

<p><input type= “button” name=”calcBtn8″ value=”Calculate”

onclick=”calc(this.form.areaBox8,this.form.widthBox8.value,this.form.lengthBox8.value)”></p>
<label>The area is: <input type=”text” name=”areaBox8″ size=”12″ readonly></label>
&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</body>
</html>
[/CODE]

the only difference is the image and the tables in dreamweaver

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@James_GatkaFeb 08.2006 — Have you installed Mozilla Firefox? You can find many common errors using the Firefox JavaScript console. Open the file locally in Firefox, click Tools | JavaScript console, and it will point you to the line that causes the error, and tell you why.
Copy linkTweet thisAlerts:
@James_GatkaFeb 08.2006 — I did just that now, and it told me that you have an extra } at the bottom of your code.

[CODE]
f.value = calcArea(length,width);
//f.squaremeterBox.value = squaremeter;
}
}
</script>[/CODE]
Copy linkTweet thisAlerts:
@mohammed_hajatauthorFeb 08.2006 — thats not the problem.. its the calculations that are not working.
Copy linkTweet thisAlerts:
@James_GatkaFeb 08.2006 — Firefox says that's where there's a "syntax" error in your code. Use some self-help.
Copy linkTweet thisAlerts:
@mohammed_hajatauthorFeb 08.2006 — thanx, il try that. i have been going over the code all day! soo tired.. lol. thanx for all your help.
Copy linkTweet thisAlerts:
@James_GatkaFeb 08.2006 — I got rid of the extra } and the next error is that "this.form has no properties" You don't have any form tags in the DW version. You can do all of this for yourself, you see.
Copy linkTweet thisAlerts:
@mohammed_hajatauthorFeb 08.2006 — yep.. that was the problem.. soo sorry for being a pain.. im at the bottom of the learning curve. its a testing time. thanx.
×

Success!

Help @mohammed_hajat 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,
)...