Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Totally a new guy here, stumped on "Sam's Teach Yourself" programming

html javascript

Best Answer wim DC, 30 June 2015 - 10:45 AM

promt should be spelled as "prompt".

 

Browsers will actually tell you what's wrong, depending on the browser you use you can press F12 in most and look for a javascript error log or something.

In this case my browser says

 

test.html:15 Uncaught ReferenceError: promt is not defined

So the browser sees an error on line 15 in your code, saying promt is not defined

Go to the full post


This topic has been archived. This means that you cannot reply to this topic.
5 replies to this topic

#1 slewis185

slewis185

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 29 June 2015 - 04:28 PM

Okay, to start off I am super new to coding (first post here btw) and am reading the book "Beginning Programming" in the Sam's Teach Yourself line of books.

In the Book it gave me some example's to try and load in a browser to see how everything is displayed and reacts.

I am trying to get this script from the book example to load up in my browser but nothing is displayed. 

I copied this straight out of the book and usually their examples load up flawlessly, but I can't get this to work and it is driving me crazy because I don't want to just shrug it off and keep reading on past it. I want it to work.

 

<!DOCTYPE html>
<html>
<body>
<script>
//filenameL AreaHalf.html
//program that calculates and prints the area
//of a circle and half circle.
document.write("The area of a circle with a radius of 3 is ") ;
document.write(3.1416*3*3) ;
document.write("<br>The area of one-half that circle is ") ;
document.write(3.1416*3*3) /2) ;
</script>
</body>
</html>
 
It seems the lines inside <script></script> just aren't even registering. 
If anyone could drop some knowledge on me I'm really wanting to learn all I can. Thanks!


#2 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts

Posted 29 June 2015 - 11:30 PM

You simply have 1 closing bracket too much here

document.write(3.1416*3*3) /2) ;


#3 slewis185

slewis185

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 30 June 2015 - 10:20 AM

thank you! it worked like a charm. I have one more of the same issue and I am trying to see if it wont run for the same problem or what, but I'm stumped on this and it's copied straight from the book I am using.

 

<!DOCTYPE html>
<html>
<head>
<title>Calculating the area of a circle</title>
</head>
<body>
<script>
 
//Filename areacircle2.html
//program that calculates and prints the area
//of a circle and half circle
 
var pi = 3.14159; // mathematical value of PI
//Ask the user for the size of the circle
var radius = promt("What is the radius of the circle?");
 
//calculate the area of the whole circle
var area = pi*radius*radius;
 
//Making these parts of the message to user strings
//both demonstrates strings and makes the alert fit
//more cleanly on a single line.
 
var message1 = " The area of a circle with the radius of ";
var message2 = " is ";
alert(message1 + radius + message2 + area);
 
alert("The area of a half circle is " + area/2);
 
</script>
</body>
</html>


#4 wim DC

wim DC

    Roar

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 2681 posts

Posted 30 June 2015 - 10:45 AM   Best Answer

promt should be spelled as "prompt".

 

Browsers will actually tell you what's wrong, depending on the browser you use you can press F12 in most and look for a javascript error log or something.

In this case my browser says

 

test.html:15 Uncaught ReferenceError: promt is not defined

So the browser sees an error on line 15 in your code, saying promt is not defined



#5 slewis185

slewis185

    CC Lurker

  • New Member
  • Pip
  • 3 posts

Posted 30 June 2015 - 11:02 AM

That fixed it. Thank you for the help and the browser tip. I have a lot to learn!



#6 TECHNECK

TECHNECK

    CC Newcomer

  • Member
  • PipPip
  • 12 posts

Posted 10 July 2015 - 07:12 AM

That fixed it. Thank you for the help and the browser tip. I have a lot to learn!

 

I recommend these books very easy for beginners to understand and learn and they have many other languages as well for sell.

 

HTML

http://www.amazon.co...html easy steps

 

CSS3

http://www.amazon.co...html easy steps






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download