Register on the forum now to remove ALL ads + popups + get access to tons of hidden content for members only!
Site Owners Forums - Webmaster ForumsCalendarContact Us

Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > Javascript


Reply
 
Thread Tools Rate Thread Display Modes
Old 08-05-2002, 11:45 PM   #1
marion
Registered User
 
Join Date: Mar 2002
Location: VA
Posts: 1,630
Question Carriage Return

Here's the deal: I have an alert and by using \n I can get it to do a carriage return in the alert box. Is it possible to transfer this to the text output by the HTML?

If the \n is place in a document.write() statment, it doesn't appear, but the return isn't visible, nor does it become apparent on copy and paste of the text in to tex editor.

Any ideas?

FYI: It must be a carriage return of sometype. HTML tags will not work, or I'd just throw in a <br> or two.
marion is offline   Reply With Quote

Old 08-07-2002, 01:11 PM   #2
joeboe
Registered User
 
joeboe's Avatar
 
Join Date: Mar 2002
Location: Sidney, NE, USA
Posts: 309
Send a message via AIM to joeboe Send a message via MSN to joeboe Send a message via Yahoo to joeboe
It works fine just like this:

<pre>
<script language="JavaScript">
line = "this \n is \n a \n bunch \n of \n lines";
document.writeln(line);
</script>
</pre>

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Never Underestimate the Power of Stupid People in Large Groups.
joeboe is offline   Reply With Quote
Old 08-07-2002, 09:51 PM   #3
marion
Registered User
 
Join Date: Mar 2002
Location: VA
Posts: 1,630
Here's the deal

I was working on the attached script, and I'm trying to get it to issue a line return in the body of the email to seperate the form values.

Any ideas?
Attached Files
File Type: txt jsmailtotest.txt (978 Bytes, 202 views)
marion is offline   Reply With Quote
Old 08-08-2002, 11:10 AM   #4
joeboe
Registered User
 
joeboe's Avatar
 
Join Date: Mar 2002
Location: Sidney, NE, USA
Posts: 309
Send a message via AIM to joeboe Send a message via MSN to joeboe Send a message via Yahoo to joeboe
Figured it out...

FINALLY... this one had my brain going. You've got to use a handy string property called fromCharCode()

basically I added a line like this:

var newLine = String.fromCharCode(0013); //inputs the ASCII character for a carraige return.

So you can use newLine for the carriage return anywhere you please. The script works fine like this:

Code:
<html>
<head>
</head>
<body>
<form name="mailForm">
<input type="hidden" name="sendTo" value="email@address.com">
<input type="hidden" name="subject" value="JavaScript Email Submitter">
Name: <input type=text name=name><br>
Email: <input type=text name=email><br>
Body:<br><textarea name="body" rows=10 cols=50 onblur="checkValues()"></textarea><br>
<input type=button value="Compile Email" onclick="runTest()">
<script type=text/javascript>
<!--
to = document.mailForm.sendTo.value;
subject = "?subject="+document.mailForm.subject.value;

function checkValues(){
	var newLine = String.fromCharCode(0013);  //inputs the ASCII character for a carraige return.
	name = "name: "+document.mailForm.name.value+ " ";
	email = "email: "+document.mailForm.email.value + " ";
	body = "&body=" + name + newLine + email + newLine + document.mailForm.body.value;
}


function runTest(){
document.getElementById('testValues').innerHTML="<a href='mailto:"+to+subject+body+"'>Click\tMe To Send Email!</a>";
}
// -->
</script>
</form>
<div id=testValues></div>
</body>
</html>
There you have it.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Never Underestimate the Power of Stupid People in Large Groups.
joeboe is offline   Reply With Quote
Old 08-08-2002, 12:06 PM   #5
marion
Registered User
 
Join Date: Mar 2002
Location: VA
Posts: 1,630
BooYah!

Excellent!

joeboe you rock dude!
marion is offline   Reply With Quote
Old 08-08-2002, 09:33 PM   #6
marion
Registered User
 
Join Date: Mar 2002
Location: VA
Posts: 1,630
OH No!

Um... Joe,

It's not working.

I copied the script, with your modification, but it's not working. It's all still on one line.

Thanks for trying. Much appreciated.
marion is offline   Reply With Quote
Old 08-09-2002, 09:04 AM   #7
joeboe
Registered User
 
joeboe's Avatar
 
Join Date: Mar 2002
Location: Sidney, NE, USA
Posts: 309
Send a message via AIM to joeboe Send a message via MSN to joeboe Send a message via Yahoo to joeboe
hmmm. very strange. What is the mail client on the machine your testing it with? I was using outlook 2000. It was also IE. version 6. It could be a compatibility issue.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Never Underestimate the Power of Stupid People in Large Groups.
joeboe is offline   Reply With Quote
Old 08-09-2002, 09:18 AM   #8
joeboe
Registered User
 
joeboe's Avatar
 
Join Date: Mar 2002
Location: Sidney, NE, USA
Posts: 309
Send a message via AIM to joeboe Send a message via MSN to joeboe Send a message via Yahoo to joeboe
FYI

Netscrape won't support this script. I get the error "document.getElementById is not a function".

I also noticed some other stuff that I believe is unique to Microshaft such as the innerHTML property that is used.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Never Underestimate the Power of Stupid People in Large Groups.
joeboe is offline   Reply With Quote
Old 08-09-2002, 09:19 AM   #9
marion
Registered User
 
Join Date: Mar 2002
Location: VA
Posts: 1,630
Ah!

At home I'm using Outlook Express 6

I'll try it at work where I'm using Outlook 2K.

I'll let you know how it goes.
marion is offline   Reply With Quote
Old 08-09-2002, 09:27 AM   #10
marion
Registered User
 
Join Date: Mar 2002
Location: VA
Posts: 1,630
Compatibility

It does work on Outlook 2K, but apparently not on Outlook Express.

It does work with NS 6.2, and no NS4.x doesn't support the getElementByID() method. NS4.x will support the innerHTML method, but you have to do some tricky coding to make it work, and I've never succesfully done it.

I know that the innerHTML will not work onLoad. It only works after the page has been parsed by the browser.
marion is offline   Reply With Quote
Old 08-13-2002, 02:54 PM   #11
joeboe
Registered User
 
joeboe's Avatar
 
Join Date: Mar 2002
Location: Sidney, NE, USA
Posts: 309
Send a message via AIM to joeboe Send a message via MSN to joeboe Send a message via Yahoo to joeboe
Is your outlook set to use html format in a message by default? That would effect the way a new line is displayed.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Never Underestimate the Power of Stupid People in Large Groups.
joeboe is offline   Reply With Quote
Old 08-13-2002, 03:35 PM   #12
marion
Registered User
 
Join Date: Mar 2002
Location: VA
Posts: 1,630
Yes

Yep,

HTML is the default format.
marion is offline   Reply With Quote
Old 08-16-2002, 09:54 AM   #13
joeboe
Registered User
 
joeboe's Avatar
 
Join Date: Mar 2002
Location: Sidney, NE, USA
Posts: 309
Send a message via AIM to joeboe Send a message via MSN to joeboe Send a message via Yahoo to joeboe
See now that presents a whole other problem. How would one go about detecting the settings in the default email editor?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Never Underestimate the Power of Stupid People in Large Groups.
joeboe is offline   Reply With Quote
Old 08-16-2002, 10:28 AM   #14
avyworld
Registered User
 
Join Date: Mar 2002
Location: La La Land
Posts: 105
Send a message via AIM to avyworld
Quote:
I also noticed some other stuff that I believe is unique to Microshaft such as the innerHTML property that is used.
Actually, Netscape does support it. It's supported it since NS6. Although, I wouldn't recommend using it. It is better to go standardized: that's where the DOM is headed (even if the end of the road is years away).

Hope that helps!

Happy coding!
__________________
del society.exe
- if only you could use a command line in the real world
avyworld is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Who Else Wants To Get 300% Return On Investment !! wilsonkck84 Making money on the web 0 08-25-2006 11:07 PM
Please review my website, will return the favour bad_bob00 Review My Website 7 08-24-2006 07:28 PM
Best return on investment pure Making money on the web 1 04-25-2006 01:31 PM
How to validate Multiple Email addresses in a form input box webbgirl Javascript 2 06-06-2005 09:59 AM


All times are GMT -7. The time now is 08:34 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Kindly hosted by OH Telecom servers (get one!)
Site Delivered By Liberty Of Mind - #1 Adult & Mainstream Solutions Provider