Results 1 to 5 of 5

Thread: how to capture textarea content format and embed it in html style email?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    malaysia
    Posts
    89

    Resolved 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.

  2. #2
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    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!

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: how to capture textarea content format and embed it in html style email?

    You can use an IFRAME control to allow for formatting.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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 
    fonts.length 1>= 0i--) {
                                                    
    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, "&amp;").replace(/"/g, "&quot;");
                                            //    return(t.replace(/</g, "&lt;").replace(/>/g, "&gt;"));
                                            //}
                                            
                                            
    function HTMLEncode(t) {
                                                var 
    str = new String(t);
                                                
    str str.replace(/&/g"&amp;");
                                                
    str str.replace(/</g"&lt;");
                                                
    str str.replace(/>/g"&gt;");
                                                
    str str.replace(/"/g, "&quot;");
                                                
                                                
                                                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

  5. #5

    Thread Starter
    Lively Member
    Join Date
    May 2004
    Location
    malaysia
    Posts
    89

    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
  •  



Click Here to Expand Forum to Full Width