inherit
31940
0
Jul 27, 2011 13:50:35 GMT -8
¿J-pop?
2,286
October 2004
darkryu2
|
Post by ¿J-pop? on Oct 24, 2009 12:21:37 GMT -8
Hey Proboarders, I''m currently taking a Computing class and we were just introduced to a few things in JavaScript such as alerts and prompts.
However I'm having a problem; the +yourname is displaying as NaNa
<html> <head> <title> Homework 7 </title> </head> <body> <script type="text/javascript" language="javascript"> <!--
yourname = prompt("What is your favorite sport?" ); document.write( + yourname + " is my favorite sport too"); // --> </script> </body>
</html>
</html>
Another thing, i'm trying to get +yourname in italics. I've tried using the <i> </i> tags but it isn't working:
<html> <head> <title> Homework 7 </title> </head> <body> <h2> <script type="text/javascript" >
yourname = prompt("What day is it today?" ); document.write("Today is " <i> + yourname + </i> " Have a nice day!"); </script> </h2> </body>
</html>
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Oct 24, 2009 13:13:14 GMT -8
The prompt function takes two parameters with the second being the default value. It's normally left blank like this.
var yourname = prompt("What day is it today", "");
Also, you don't need the concatenation operator before the variable on this line.
document.write( + yourname + " is my favorite sport too");
And the <i>'s are strings, so they need to be in quotes like this.
document.write("Today is <i>" + yourname + "</i> Have a nice day!");
|
|
inherit
31940
0
Jul 27, 2011 13:50:35 GMT -8
¿J-pop?
2,286
October 2004
darkryu2
|
Post by ¿J-pop? on Oct 24, 2009 14:01:53 GMT -8
Hey Jordan, I understood everything except the first part:
What exactly is left blank? We didn't go over terms that heavily, so I may be confused at that part.
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Oct 24, 2009 14:10:18 GMT -8
You forgot your default value, I believe. If you just had var yourname = prompt("What day is it today?", ""); If you add something to the second set of quotations, it will show up in the prompt before you enter anything
|
|
inherit
31940
0
Jul 27, 2011 13:50:35 GMT -8
¿J-pop?
2,286
October 2004
darkryu2
|
Post by ¿J-pop? on Oct 25, 2009 7:05:18 GMT -8
Ah, I see; you've explained it very well guys. Thanks for the assistance .
|
|
inherit
97216
0
Nov 26, 2024 13:53:14 GMT -8
Bennett 🚀
Formerly iPokemon.
3,622
January 2007
catattack
iPokemon's Mini-Profile
|
Post by Bennett 🚀 on Oct 25, 2009 7:12:05 GMT -8
No problem
|
|