0
<HTML> 
<HEAD> 
<TITLE>TMA 02 Q4(ii)</TITLE> 
<SCRIPT LANGUAGE = "JAVASCRIPT"> 
var loc;
var weather;
var name;

loc = window.prompt('Please enter your location',''); 
weather = window.prompt(`Please enter the weather`,``); 
name = window.prompt(`Please enter your name`,``);

document.write(`London`;` Snowing`;` Meriam`);
document.write(`<BR>` + `See you soon`)

</SCRIPT> 
</HEAD> 
<BODY> 
</BODY> 
</HTML>

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by benqus
0

Is it correct?

No!
a.) To delimit the strings you can use either DOUBLE QUOTES (") OR APOSTROPHES('). You are using the backtick(`) which is NOT correct
b.) On the document.write() you need to separate different string using a comma(,) NOT a semicolon( ; )

Edited by hielo: n/a

0
<HTML> 
<HEAD> 
<TITLE>TMA 02 Q4(ii)</TITLE> 
<SCRIPT type="text/javascript"> 
 
var loc = window.prompt("Please enter your location:", ""); 
var weather = window.prompt("Please enter the weather:", ""); 
var name = window.prompt("Please enter your name:", "");
 
document.write(loc+", "+weather+", "+name+"<br />See you soon!");
 
</SCRIPT> 
</HEAD> 
<BODY> 
</BODY> 
</HTML>

- The attribute of the script called 'language' is deprecated as far as I know. Use type="text/javascript" instead.

- You don't have to predefine the variables you are going to use. They live as long as the function exists, so you don't have to apply them globally.

- Don't forget DTD (strict, or transitional) from the markup! =)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.