473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

beginner javascript question

Need some help fixing this. basically, i want the second document.write to start on a new line and i am using the "\n" escape code but it is not working. I tried putting the <pre> tag around the script and it still doesnt work. Whats going on here?

<html>
<head>
<title>Javascript Run</title>

</head>
<body>

<script type="text/javascript">
var firstName = prompt("Please type in your name", "What is your first name?");
var thirdLetter = firstName.charAt(2);

alert("Hello "+firstName);


document.write("The third letter of your name is "+thirdLetter\n);
document.write("That is your character right ?");
</script>


</body>

</html>
Jan 18 '07 #1
4 919
vituko
48
\n => <br/>
Jan 18 '07 #2
acoder
16,027 Expert Mod 8TB
Two things, one is as vituko mentioned: change \n to <br>
Secondly, it must be included within the string:
Expand|Select|Wrap|Line Numbers
  1. document.write("The third letter of your name is "+thirdLetter+"<br>");
  2. document.write("That is your character right ?");
or
Expand|Select|Wrap|Line Numbers
  1. document.write("The third letter of your name is "+thirdLetter);
  2. document.write("<br>That is your character right ?");
Jan 18 '07 #3
when do you use the "\n" then? I have played around with it before and it did work but not for this example..
Jan 18 '07 #4
acoder
16,027 Expert Mod 8TB
You can use "\n" in a popup box, e.g. alert, prompt or confirm to give your information/question over two or more lines.
Jan 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

19
by: What-a-Tool | last post by:
I have a school project (ASP) in which I have to call three different ASP pages from three different and identical (except for the form "action", obviously) HTM pages. This I have no problem with....
14
by: japin0 | last post by:
Hi, I am a absolute beginner in ASP ..I do have a bit of exposure to .VBS and other scripting languages. I need your guidance, where do I start? I had been to MS website Quick start guide but it...
5
by: Jozef | last post by:
Hello, I have done a little "old" ASP work along with some javascript. I'm currently getting into ASP.net and would like to step up my game overall with regard to Web Development. I was...
5
by: optimistx | last post by:
As a beginner in javascript I had a question. I was reading FAQ and posts here. I became very unhappy: Obviously this group is mainly for wise, pedantic, unkind etc people, who already know...
6
by: jan | last post by:
My apologies for being a javascript beginner and asking such a basic question. This is probably so easy that nobody ever mentions it. Tutorials and places that tell of basic commands never seem to...
1
by: vocalise | last post by:
The title probably isn't very clear, but I haven't been able to find this problem (or I must be having problems figuring out which search strings to use) so I apologize if this has been addressed...
13
by: sathyashrayan | last post by:
Dear group, pls go through the following function definition: function at_show_aux(parent, child) { var p = document.getElementById(parent); var c = document.getElementById(child); var top ...
2
by: OrdinarySpore | last post by:
Hi. I am having a problem with a simple IF statment on this Javascript. I found this script on scriptsource and want to see if I can add an IF statment to display a "congradulations" line of text...
9
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I followed first walk through sample from http://ajax.asp.net/docs/tutorials/IntroductionUpdatePanel.aspx to create my first testing page, The problem is after I clicked that botton, it...
25
by: doznot | last post by:
Let's say you want to use Moodle to teach an introductory class in PHP programming. Some of the students have little or no computer experience. In addition to background reading and...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.