Jump to content

Comparison Operators parsed as HTML tags?


kingnutter

Recommended Posts

Hi Everyone,

 

I've typed this example from "Beginning Javascript" and it doesn't seem to work:

 

[pre]<html>

<head>

</head>

<body>

 

<script language=JavaScript type="text/javascript">

 

var degFahren = new Array(212, 32, -459.15);

var degCent = new Array();

var loopCounter;

 

for (loopCounter = 0; loopCounter <= 2; loopCounter++)

{

degCent[loopCounter] = 5/9 * (degFahren[loopCounter] - 32);

}

 

for (loopCounter = 2; loopCounter >= 0; loopCounter--)

{

document.write("Value " + loopCounter + " was " + degFahren[loopCounter] + " degrees Fahrenheit");

document.write(" which is " + " degCent[loopCounter] + " degrees centigrade<BR>");[pre][/pre]

}

 

</script>

</body>

</html>[/pre]

 

Nothing is mentioned in the online erratum. However this very similar program cut and pasted from the internet DOES work:

[pre]

<HTML> <HEAD> <TITLE>for example</TITLE> </HEAD>

<BODY>

<SCRIPT LANGUAGE=JavaScript>

 

var degFahren = new Array(212, 32, -459.15);

var degCent = new Array();

var loopCounter;

 

for (loopCounter = 0; loopCounter <= 2; loopCounter++) {

 

degCent[loopCounter] = 5/9 * (degFahren[loopCounter] - 32);

}

 

for (loopCounter = 2; loopCounter >= 0; loopCounter--) {

 

document.write("Value " + loopCounter + " was " +

degFahren[loopCounter] + " degrees Fahrenheit");

 

document.write(" which is " + degCent[loopCounter] +

" degrees centigrade<BR>");

}

 

</SCRIPT>

</BODY>

</HTML>[/pre]

 

 

I'm pretty sure it is because in the former the <= sign opens as an html tag, but I can't see what the difference between the two sets of codes is except a different case in the head of the latter and different script language definitions.

 

I am typing and testing the code in HyperEdit on a MacBook and also testing on Firefox with the same results.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/96304-comparison-operators-parsed-as-html-tags/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.