/    Sign up×
Community /Pin to ProfileBookmark

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>[/CODE]

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>[/CODE]

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERAug 24.2013 — 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 'nn' to the end of the <textarea> values before submission?
Copy linkTweet thisAlerts:
@PadonakAug 25.2013 — is it nornal to have 3 equal id?
Copy linkTweet thisAlerts:
@JMRKERAug 25.2013 — Nope. Good call.

They MUST be unique.
Copy linkTweet thisAlerts:
@premium_copyauthorAug 26.2013 — 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 'nn' to the end of the <textarea> values before submission?[/QUOTE]



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=

[/quote]


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?

<i>
</i>
&lt;script&gt;
$('textarea').each(function(){ $(this).val( $(this).val() + 'nn' ); }); <br/>
&lt;/script&gt;
Copy linkTweet thisAlerts:
@PadonakAug 26.2013 — [I]Microsoft has confirmed that this is a problem in the Microsoft products...[/I]

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

Success!

Help @premium_copy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...