Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Forms have no text spacing

Status
Not open for further replies.

BobTB

Technical User
Oct 28, 2002
37
AU
I have a form that uses the script below. The form has three body text fields. When the form is subm,itted it opens the default email software ok in IE6 and NS7. The problem is that the fields that place the text into the body of the email all appear on the same line with no spaces between, or above or below. Is there a way automatically place a horizontal space between each field when it displays in the body of the email?

See script below

<Head>
<script>

function createEmail() {

document.location.href = &quot;mailto:youremailaddress.com?subject=Feedback&quot; + &quot;&body=&quot; + document.email.name.value + document.email.emailaddress.value + document.email.messagebody.value;

}
</script>

<Body>
<td><form name=email method=&quot;POST&quot; action=&quot;mailto:youremailaddress.com?subject=Send your Feedback/Comments&quot; enctype=&quot;text/plain&quot;>name: <input type=text name=name size=&quot;20&quot;><p>email: <input type=text name=emailaddress size=&quot;20&quot;></p><p><br>text:<br><textarea name=messagebody rows=2 cols=30></textarea><br><input type=button value=&quot;send email&quot; onclick=createEmail()></p></form></td>

Thanks
 
function createEmail() {

document.location.href = &quot;mailto:youremailaddress.com?subject=Feedback&quot; + &quot;&body=&quot; + document.email.name.value + &quot; &quot; + document.email.emailaddress.value + &quot; &quot; + document.email.messagebody.value;

}
Water is not bad as long as it stays out human body ;-)
 
hi Targol,

I have tried this but it still doesn't place a space between the fields

What could be wrong?
 
I have placec a space between the qoutes &quot; &quot; and it gives me 'hello hello hello'.........but i need it to display in the email body as

hello
hello
hello
 
Try to change your script to this :
Code:
<script>

function createEmail() {
var mailBody=document.email.name.value + &quot; &quot; + document.email.emailaddress.value + &quot; &quot; + document.email.messagebody.value;
alert (mailBody);
document.location.href = &quot;mailto:youremailaddress.com?subject=Feedback&quot; + &quot;&body=&quot; + mailBody;
}
</script>
Does the Alert show the texe with or without the spaces ? Water is not bad as long as it stays out human body ;-)
 
place <BR> breaks in the &quot; &quot; space places to put line breaks in it A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
The alert shows the text with spaces but still not correctly

It shows fieldtext1 fieldtext2 fieldtext3

Can you get it to place each field on a new line in the email body
 
'scuse me, I answered before your second post. To add a carriage return , try this :
Code:
<script>

function createEmail() {
var mailBody=document.email.name.value + String.fromCharCode(13) + document.email.emailaddress.value + String.fromCharCode(13) + document.email.messagebody.value;
alert (mailBody);
document.location.href = &quot;mailto:youremailaddress.com?subject=Feedback&quot; + &quot;&body=&quot; + mailBody;
}
</script>
I'm not sure of the integer value 13 : it's ascii value for carriage return but the String.fromCharCode wants unicode value. May be it's the same one. If not, find the unicode value for CR. Water is not bad as long as it stays out human body ;-)
 
The onpnt solution is the better one if your email client accepts html formed mails. Water is not bad as long as it stays out human body ;-)
 
The unicode value is \u000D

Do i place this in the brackets where the 13 is?

Unicode Value Name Symbol
\u0009 Tab <TAB>
\u000B Vertical Tab <TAB>
\u000C Form Feed <FF>
\u0020 Space <SP>
\u000A Line Feed <LF>
\u000D Carriage Return <CR>
\u0022 Double Quote <TAB>
\u0027 Single Quote <'>
\u005C Backslash <\>

 
000D is the hex value for 13. so the char value is the same in unicode than in ascii. The code I posted before should work. Water is not bad as long as it stays out human body ;-)
 
I have placed the script with the char(13) but it still only gives me a space between each field text but it leaves them all on the same line.....do you know of any other way to display each field on a seperate line
 
2 solutions :
- try onpnt idea (&quot;<BR/>&quot; between each input value) or
- try CR + LF instead of CR alone :
Code:
... String.fromCharCode(13) + String.fromCharCode(10) + ...
as certain OSs use the 2 chars instead on one. Water is not bad as long as it stays out human body ;-)
 
Hi
I've been following this and trying different things, but just happended to come across this FAQ in the HTML forum.
FAQ215-926

I haven't tried it yet, but it looks like it may help.

Terry
 
Hi HellTel

I tried the sugestion in the FAQ and it now works after placing the &quot;%0d&quot; in there with Outlook etc when using IE browser, but it still doesn't drop each field onto it's own line in the Netscape Email software.

function createEmail() {

document.location.href = &quot;mailto:youremailaddress.com?subject=Feedback&quot; + &quot;&body=&quot; + document.email.name.value + &quot;%0d&quot; + document.email.emailaddress.value + &quot;%0d&quot; + document.email.messagebody.value;

}


Dont know where to go from here........????????
 
Well, one stage further is better than no stages further, I suppose. I'll keep looking.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top