PDA

View Full Version : Passing an email address, supplied by the user, into the CC field..?



NGJ
04-18-2006, 08:30 AM
Hi,

I'm using a company standard .asp mailing form though I'd like to be able to put a value into the cc field based on content entered by the user on the form itself.

e.g. "If you'd like to receive a copy of this form, please enter your email address here".., etc.

Is it possible to pass this value back and put it into the code as a variable?
I've tried the following, but it doesn't seem to work....

(within the table)
<textarea name="email_copy" rows="1" cols="50"
wrap=virtual>???name here???@email.address.com</textarea>

then...

<input type="hidden" name="mailcc" value=email_copy>

Any help on this would be really appreciated !

Thanks in advance,

N.

Twey
04-18-2006, 09:33 AM
Maybe you could give us the code?

NGJ
04-18-2006, 10:17 AM
Ok,
Here we go... I've reduced the Form down to save time...


<BODY>
<form method="post" action="/lib/common/mailing.asp">

<table width=100%>

<tr>
<td valign=top align=left><tt><b>Enter your email address to receive a copy (recommended!) of your request:</b>
</tr>

<tr>
<td valign=top><textarea name="email_copy" rows="1" cols="50" wrap=virtual>@email.co.uk</textarea><br></td></tr>
</table>

<input type="hidden" name="mailto" value="email@address.co.uk">
<input type="hidden" name="mailcc" value=email_copy><!-- <input type="hidden" name="mailbcc" value=""> -->

<input type="hidden" name="mailsubject" value="Form">
<input type="hidden" name="htmloutput" value="yes">

<input type="hidden" name="orderby" value="Name,Dept,Telephone_number,Choices,Checkbox 1,Checkbox 2,Comments">
<input type="hidden" name="senttext" value="Your form has been sent. We will contact you as soon as possible.">

<table width="100%">
<tr>
<td valign="top">Name:</td>
<td><input name="Name" size="30" style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" ></td>
</tr>
<tr>
<td valign="top">Dept:</td>
<td><input name="Dept" size="30" style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" ></td>
</tr>

.... other FORM elements....

<input type="submit" value="Send"></p></td>
</tr>
</table></form>

</body>
</html>



Any thoughts .... ?;)

Twey
04-18-2006, 10:51 AM
No, it's not the form I need, it's the contents of /lib/common/mailing.asp :)

NGJ
04-18-2006, 01:22 PM
I cannot easily get hold of that I'm afraid.

Thinking on, is there some way of passing a value (maybe via JS?) - using on Submit? :confused:

Thanks again in advance,

N.

Twey
04-18-2006, 01:53 PM
Ah, I think I see: You want to copy the value of one textarea to another? That's more easily done.
<script type="text/javascript">
var copying = false;

function copy(formNum, fromName, toName) {
if(!copying) return;
var from = document.forms[formNum].elements[fromName],
to = document.forms[formNum].elements[toName];
to.value = from.value;
window.setTimeout("copy('" + formNum + "', '" + fromName + "', '" + toName + "')", 300);
}

function beginCopy(formNum, fromName, toName) {
copying = true;
copy(formNum, fromName, toName);
}

function endCopy() {
copying = false;
}
</script>
<textarea name="email_copy" onkeydown="beginCopy(0, this.name, 'mailcc');" onkeyup="endCopy();" rows="1" cols="50" wrap=virtual>@email.co.uk</textarea><br></td></tr>
</table>

<input type="hidden" name="mailto" value="email@address.co.uk">
<input type="hidden" name="mailcc" value="email_copy">

NGJ
04-18-2006, 02:28 PM
Brilliant - It works a treat!

Thank you Twey !!!:)

NGJ
06-08-2006, 08:21 AM
TWEY/All,

I've been using the below code - changing it slightly, this time, to copy a value into the subject field instead. This then makes the email trail easier to view in the INBOX, for the user, as the subject reads something they quickly recognise. What I'd like to know is how can I join another value to it?

eg., the subject will be

"my bit of text" + the value copied from projectname

So, somehow I need to adjust:
<input type="hidden" name="mailsubject" value="projectname">


To capture the input from the user...
<input type="text" name="projectname" onkeypress="return handleEnter(this, event)" onkeydown="beginCopy(0, this.name, 'mailsubject');" onkeyup="endCopy();" class="memorize" value="1-" size="16" MAXLENGTH=8>


Thanks in advance,

N.



As a reminder...

The original code supplied by TWEY
<script type="text/javascript">
var copying = false;

function copy(formNum, fromName, toName) {
if(!copying) return;
var from = document.forms[formNum].elements[fromName],
to = document.forms[formNum].elements[toName];
to.value = from.value;
window.setTimeout("copy('" + formNum + "', '" + fromName + "', '" + toName + "')", 300);
}

function beginCopy(formNum, fromName, toName) {
copying = true;
copy(formNum, fromName, toName);
}

function endCopy() {
copying = false;
}
</script>
<textarea name="email_copy" onkeydown="beginCopy(0, this.name, 'mailcc');" onkeyup="endCopy();" rows="1" cols="50" wrap=virtual>@email.co.uk</textarea><br></td></tr>
</table>

<input type="hidden" name="mailto" value="email@address.co.uk">
<input type="hidden" name="mailcc" value="email_copy">


(Apologies, though this is really JScript - I've left this in the ASP section where it was originally posted).

Twey
06-08-2006, 11:10 AM
var copying = false;

function copy(formNum, fromName, toName, prefix) {
if(!copying) return;
var from = document.forms[formNum].elements[fromName],
to = document.forms[formNum].elements[toName];
to.value = (prefix ? prefix : "") + from.value;
window.setTimeout("copy('" + formNum + "', '" + fromName + "', '" + toName + "'" + (prefix ? ", '" + prefix + "'" : "") + ")", 300);
}

function beginCopy(formNum, fromName, toName, prefix) {
copying = true;
copy(formNum, fromName, toName, prefix);
}

function endCopy() {
copying = false;
}

NGJ
06-08-2006, 01:36 PM
Thanks for the response! From this code, can you please highlight which prefix ? text parts I should be changing to my required prefix text?

I think I'm doing it wrong !:p

Thanks again!

N.

Twey
06-08-2006, 03:53 PM
You'd just do, for example:
<input type="text" name="projectname" onkeypress="return handleEnter(this, event)" onkeydown="beginCopy(0, this.name, 'mailsubject', 'your bit of text');" onkeyup="endCopy();" class="memorize" value="1-" size="16" maxlength="8">

NGJ
06-08-2006, 04:28 PM
That works great - thank you! :)

Just to continue being a pain (:p )...
Is it much of a job to turn this around to work as a suffix instead?
I'm thinking, I could probably use the same script for copying both the input from the user for the email subject name and, also, again (but in not declaring a suffix element) for copying an email address input into the cc field - assuming leaving this out of the function wouldn't have a bad effect and screw up the email element?

Again, I really appreciate your help.

Cheers,

N.

NGJ
06-08-2006, 08:40 PM
Yup - it's been a long day and I obviously wasn't thinking when I sent that last question.... Of course, I can switch it around by either having a value in there or leaving it blank.

Cheers,

N.:D