|
-
Apr 20th, 2005, 03:08 AM
#1
Thread Starter
Lively Member
how to capture textarea content format and embed it in html style email?
Code:
<textarea id="mailContent" title="Email Content" maxLength="1500" name="mailContent" cols="77" rows="16"></textarea>
Hi, i have the code above to let a user type in message and then the user will click a send button to send content in the textarea as a html email(this is my intention).
however, during my test, i find that all content in the textarea are in plain text, ie, it dont have paragraph or empty line as in what i gave type in the textarea.
can someone help, teach me how to capture the origainal format of text area and send it as it is in the email.
Last edited by kkc; Apr 20th, 2005 at 09:41 PM.
-
Apr 20th, 2005, 03:21 AM
#2
Frenzied Member
Re: how to capture textarea content format and embed it in html style email?
Do you mean you want to capture rich text rather than plain text that the textarea only uses.
You'll need a third party control such as http://www.freetextbox.com/ - this is a control for ASP.NET sorry but I'm not aware of one for ASP. I expect someone else here will though!
DJ
If I have been helpful please rate my post. If I haven't tell me!
-
Apr 20th, 2005, 04:11 AM
#3
Re: how to capture textarea content format and embed it in html style email?
You can use an IFRAME control to allow for formatting.
-
Apr 20th, 2005, 04:19 AM
#4
Re: how to capture textarea content format and embed it in html style email?
Quick example of what I've done:
Code:
<td vAlign="top" align="left" width="100%" colSpan="4"><table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td width="2%"></td>
<td width="96%" colSpan="3"><iframe class="csBodyText" id="idContent" width="100%" onload="populateIFrame(); document.forms.frmResume.txtFullName.focus();"
height="500"></iframe>
</td>
<td width="2%"><input id="txtResumeHTML" type="hidden" runat="server"></td>
</tr>
<tr>
</tr>
</table>
</td>
Then some javascript:
PHP Code:
<script language="javascript" type="text/javascript">
function populateIFrame(){
setMode(1);
idContent.document.body.innerHTML = document.frmResume.txtResumeHTML.value;
setMode(0);
}
function document.onreadystatechange()
{
idContent.document.designMode="On";
}
function cleanHtml() {
var fonts = idContent.document.body.all.tags("FONT");
var curr;
for (var i = fonts.length - 1; i >= 0; i--) {
curr = fonts[i];
if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML;
}
}
function setMode(newMode) {
bTextMode = newMode;
var cont;
if (bTextMode) {
cleanHtml();
cleanHtml();
cont=idContent.document.body.innerHTML;
idContent.document.body.innerText=cont;
} else {
cont=idContent.document.body.innerText;
idContent.document.body.innerHTML=cont;
}
idContent.focus();
}
// function HTMLEncode(t) {
// var t = t.toString().replace(/&/g, "&").replace(/"/g, """);
// return(t.replace(/</g, "<").replace(/>/g, ">"));
//}
function HTMLEncode(t) {
var str = new String(t);
str = str.replace(/&/g, "&");
str = str.replace(/</g, "<");
str = str.replace(/>/g, ">");
str = str.replace(/"/g, """);
return str;
}
//"
function savedocument() {
setMode(1); //switch doc to html mode for save
document.frmResume.txtResumeHTML.value=HTMLEncode(idContent.document.body.innerText);
setMode(0); //switch doc back to text mode
}
</script>
In the button click event, I take the value in the iframe, save it to the hidden field and work with it in code.
HTH
-
Apr 20th, 2005, 09:40 PM
#5
Thread Starter
Lively Member
Re: how to capture textarea content format and embed it in html style email?
thanx.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|