www.webdeveloper.com
Results 1 to 6 of 6

Thread: I hate not knowing: adding text to a textarea on submit

  1. #1
    Join Date
    Aug 2013
    Posts
    2

    I hate not knowing: adding text to a textarea on submit

    This seems to be pretty basic but I cannot get it exactly the way I want it. Note: I have been looking for 4 days on how to resolve this.


    Issue:

    I created a form to be used on my work intranet (ie7 / Outlook) which will email the form textarea answers to the specified email address via Mailto (plain/text) and I want to add a carriage return after each text area on submit.



    Reason:

    This is for a staff quiz page (no access to php on this server so using mailto), and the text is too cramped when sent by the email. I want to add spacers between each question response.



    What I have working:

    This works but only on the textarea with ID = A1 and I have it as an onchange event. My form does not have a submit button (sent via another script) so I also not sure how to execure onSubmit.



    Code:
    <SCRIPT LANGUAGE=JavaScript>
    
    function DisplayEvent(eventName){   
    
      var myMessage = window.document.frm.a1.value;   
    
      myMessage = myMessage + eventName;   
    
      window.document.frm.a1.value = myMessage;
    
    } </SCRIPT>


    Much appreciate any help you can give.



    Here is a stripped down example of my form (note: i added in the submit button for the example)

    Code:
    <FORM NAME="mailer" id="frm" METHOD="post" ACTION="" ENCTYPE="text/plain" onSubmit="(document.mailer.action += mailtoandsubject)" >
    
    To Mail:<input  type="text" NAME="mailtoperson" onChange="msg(this.form)"  /><BR />
    
      <INPUT TYPE="hidden" SIZE=45 NAME="Enter Quiz Title Here" onChange="msg(this.form)" />                             
    
        <INPUT TYPE="hidden" SIZE=45 NAME="subject" value="Enter Quiz Title Here - hidden" onChange="msg(this.form)" /> 
    
     
    
                                     
    
        Q1: <textarea name="1" id="styled" cols="22" rows="5"></textarea><br/>
    
        Q2: <textarea name="2" id="styled" cols="22" rows="5" ></textarea><br/>
    
        Q3: <textarea name="3" id="styled" cols="22" rows="5" ></textarea><br/>
    
     
    
    <input type="submit">
    
    </form>
    
     
    
      <script type="text/javascript"> 
    
                    function msg() {
    
                    document.mailer.action = "mailto:"
    
                    mailtoandsubject = ( ( document.mailer.mailtoperson.value) + '?subject=' + document.mailer.subject.value );
    
                   
    
                    }
    
                   
    
      </script>

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,432
    I'm not sure I understand the problem, but are you trying to add new lines between the Q responses?

    If yes, have you tried to add '\n\n' to the end of the <textarea> values before submission?

  3. #3
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,670
    is it nornal to have 3 equal id?

  4. #4
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,432
    Nope. Good call.
    They MUST be unique.

  5. #5
    Join Date
    Aug 2013
    Posts
    2
    Quote Originally Posted by JMRKER View Post
    I'm not sure I understand the problem, but are you trying to add new lines between the Q responses?

    If yes, have you tried to add '\n\n' to the end of the <textarea> values before submission?

    Thanks for the reply.

    The problem is that in in Outlook 2003 the mailto response from the form quiz does not include line breaks between responses so the output looks like below. I am trying to force spaces between the questions so the output is more spaced and managable to read.

    subject=Enter Quiz Title Here - hidden
    a1=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id estLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui 2=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id estLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in 3=Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id estLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id estLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat 4= 5= 6= 7= 8= 9= 10=
    I did try some jQuery that worked but not exactly correct. The spaces are being added like a placeholder instead. I thought an onBlur would work but if someone left and came back to the box they would trigger it again. How would I change the following into an onsubmit event?

    Code:
    <script>
    $('textarea').each(function(){ $(this).val( $(this).val() + '\n\n'  ); });  
    </script>

  6. #6
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,670
    Microsoft has confirmed that this is a problem in the Microsoft products...

    ----> http://support.microsoft.com/kb/287816/en-us

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles