468,771 Members | 1,810 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,771 developers. It's quick & easy.

Mailto: with subject containing form field values.

I want to build an email subject containing text and a form field.

Have have got so far but all I seem to be able to do is generate another
page in the browser with a text string. (code attached)

I think that some how I need to pass the generated string as the action but
can't figure how to do it.

Can someone please tell me where I am going wrong and maybe suggest a
solution.

TIA
Steve
--
<HTML>
<TITLE> test</TITLE>
<HEAD>

<script language = "javascript">

function mailsubject(msubject){
var mailto = " \"mailto:wright\@wcc.govt.nz\"?Subject= ";
var subbase = "\"RAMM Record Carriageway Resurfacing Record" + "\"";
var contractno = document.resurfacingrecord.contract.value;
var method = " Method=" + "\"POST\"" + " enctype=" +"\"text" + "\/"
+"plain\"";
msub = mailto + subbase + "\"" + contractno + "\"" + method;
window.status = (msub);
return (msub);
}
</script>

</HEAD>
<body>
<form name = "resurfacingrecord" action= 'javascript:mailsubject();' >

<select name="contract">
<option value="">Select Contract</option>
<option value="RS-330">RS-330 Northern</option>
<option value="RS-331">RS-331 Southern</option>
</select>
<input type=submit value="Send Record">

</form>
</HTML>
--
Jul 23 '05 #1
3 5701
Note: I want to drive this from a submit button

Steve
"Steve Wright" <wr****@wcc.govt.nz> wrote in message
news:1084757473.167042@muldoon...
I want to build an email subject containing text and a form field.

Have have got so far but all I seem to be able to do is generate another
page in the browser with a text string. (code attached)

I think that some how I need to pass the generated string as the action but can't figure how to do it.

Can someone please tell me where I am going wrong and maybe suggest a
solution.

TIA
Steve
--
<HTML>
<TITLE> test</TITLE>
<HEAD>

<script language = "javascript">

function mailsubject(msubject){
var mailto = " \"mailto:wright\@wcc.govt.nz\"?Subject= ";
var subbase = "\"RAMM Record Carriageway Resurfacing Record" + "\"";
var contractno = document.resurfacingrecord.contract.value;
var method = " Method=" + "\"POST\"" + " enctype=" +"\"text" + "\/"
+"plain\"";
msub = mailto + subbase + "\"" + contractno + "\"" + method;
window.status = (msub);
return (msub);
}
</script>

</HEAD>
<body>
<form name = "resurfacingrecord" action= 'javascript:mailsubject();' >

<select name="contract">
<option value="">Select Contract</option>
<option value="RS-330">RS-330 Northern</option>
<option value="RS-331">RS-331 Southern</option>
</select>
<input type=submit value="Send Record">

</form>
</HTML>
--

Jul 23 '05 #2
Steve Wright wrote:
Note: I want to drive this from a submit button
I want to build an email subject containing text and a form field.

<snip>

Warning: This will have poor browser support, IE5+ NS6+ if I understand
it correctly:

<HTML>
<HEAD>
<TITLE>test mail send</TITLE>
<script type="text/javascript">
function makeForm(){
//clear div of any previous forms that might have been generated by
this function
document.getElementById('formTest').innerHTML='';
//set up variables to generate dynamic subject line
var contractno = document.getElementById('contract').value;
var mmethod = 'Method="POST" enctype="text/plain"';
var msubject= 'RAMM Record Carriageway Resurfacing Record';

// create new form on page, set it's attributes
var f=document.createElement('form');
f.setAttribute('name','formsendmail');
f.setAttribute('id','formsendmail');
f.setAttribute('action','mailto:wr****@wcc.govt.nz ?Subject=' +
msubject + ' Contract Number=' + contractno);
f.setAttribute('method',mmethod);

//insert new form into div
document.getElementById('formTest').appendChild(f) ;

}
</script>

</HEAD>
<body>

<select name="contract" id="contract">
<option value="">Select Contract</option>
<option value="RS-330">RS-330 Northern</option>
<option value="RS-331">RS-331 Southern</option>
</select>

<input type=button
onclick="makeForm();document.getElementById('forms endmail').submit()"
value="Send Record">

<div id="formTest"></div>

</body>
</HTML>

Mike

Jul 23 '05 #3
This is what I eventually used which does exactly what I want.

function buildsubject()

{

var f = document.forms['resurfacingrecord'];

var sub = "mailto:wr****@wcc.govt.nz?subject=RAMM Carriageway
Resurfacing Record " + (f.roadname.value) + " " + (f.startroad.value) + "-"
+ (f.endroad.value);

f.action = sub;

}

along with this as the form tag

<form name = "resurfacingrecord" action="about:blank" method="post"
enctype="text/plain" onSubmit="buildsubject()">

and this for the form button

<input type=submit value="Send Record">

"mscir" <ms***@access4less.com.net.org.uk> wrote in message
news:10*************@corp.supernews.com...
Steve Wright wrote:
Note: I want to drive this from a submit button
I want to build an email subject containing text and a form field.

<snip>

Warning: This will have poor browser support, IE5+ NS6+ if I understand
it correctly:

<HTML>
<HEAD>
<TITLE>test mail send</TITLE>
<script type="text/javascript">
function makeForm(){
//clear div of any previous forms that might have been generated by
this function
document.getElementById('formTest').innerHTML='';
//set up variables to generate dynamic subject line
var contractno = document.getElementById('contract').value;
var mmethod = 'Method="POST" enctype="text/plain"';
var msubject= 'RAMM Record Carriageway Resurfacing Record';

// create new form on page, set it's attributes
var f=document.createElement('form');
f.setAttribute('name','formsendmail');
f.setAttribute('id','formsendmail');
f.setAttribute('action','mailto:wr****@wcc.govt.nz ?Subject=' +
msubject + ' Contract Number=' + contractno);
f.setAttribute('method',mmethod);

//insert new form into div
document.getElementById('formTest').appendChild(f) ;

}
</script>

</HEAD>
<body>

<select name="contract" id="contract">
<option value="">Select Contract</option>
<option value="RS-330">RS-330 Northern</option>
<option value="RS-331">RS-331 Southern</option>
</select>

<input type=button
onclick="makeForm();document.getElementById('forms endmail').submit()"
value="Send Record">

<div id="formTest"></div>

</body>
</HTML>

Mike

Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Val | last post: by
2 posts views Thread by Wayne Wengert | last post: by
7 posts views Thread by Steve Wright | last post: by
3 posts views Thread by Yogi_Bear_79 | last post: by
13 posts views Thread by John Baker | last post: by
6 posts views Thread by 35th Ave Media | last post: by
2 posts views Thread by Pramod | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.