Woodley said:
Hi Trevor, no sorry I didn't receive your post. I am v.new to the
discussion groups so this in itself is a learning curve! I'd
certainly like to see the js though.
Thanks
Sorry,
I forgot to add that my post was to another query, not to yours, but it had
a very similar topic.
It can be difficult browsing the newsgroup to find queries that you are
interested in.
I use Outlook Express to read the NG. All new messages are marked, so I can
read them, delete those of no interest, keep (and possiblty reply to) those
that are, and move ones with info that could be future use to other folders.
This is some HTML and JS to create an email from a form.
I have tried to cut out the extraneous stuff so I hope it still works.
<script type="text/javascript">
function checkEmailAddress(field)
{
// the following expression in () after 'match' must be all on one line...
if
(field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi))
return true
else
{ alert('Please enter a valid e-mail address.')
field.focus()
field.select()
return false }
}
// --------------------
function testform()
{
with (document.form1)
{
if (!checkEmailAddress(Email))
return
// Add any other validity checks in here
}
}
// --------------------
function sendform()
{
with (document.form1)
{
var body = ''
var i = elements.length , j = 0
while (i-- > 2) // drop last two elements - "submit" and "reset"
{
var text = (elements[j].checked) ? 'Yes' : elements[j].value
// converts radio button answers to 'Yes'
if (text != 'on')
{
var tname = elements[j].name
body += tname
if (tname == "Comment")
body += '%0d%0a' // line break before comment text
body += text + '%0d%0a' // line break after each line of text
} // end if
j += 1
} // end while
} // end with
window.location = "mailto:" + "username" + "@" + "domain" + ".com"
+ "?subject=Response%20from%20Form1"
+ "&body=" + body
}
// --------------------
</script>
<form name="form1" action="">
<div style="background-color:#DBE0F5; padding:3px; font:75% arial;">
<b>Title</b>
</div>
<div style="padding:10px; font:75% Arial; text-align:left;">
<p>
Hi all,<br />
Some introductory text
<br /><br />
<p>
Name:<br/>
<input type="text" id="Name" value="Insert name" size="40"
onfocus="if (this.value=='Insert name'){this.value='';};return
false;"
onblur="if (this.value==''){this.value='Insert name';return
false;}"/><br/>
Email:<br/>
<input type="text" id="Email" value="Insert e-mail address" size="40"
onfocus="if (this.value=='Insert e-mail
address'){this.value='';};return false;"
onblur="if (this.value==''){this.value='Insert e-mail
address';return false;}"/><br/>
A question with a Yes/No radio button? <br/>
<input type="radio" name="yesno" />Yes <br/>
<input type="radio" name="yesno" />No <br/>
<!-- Add other questions in here -->
Enter Comment:<br/>
<textarea id="Comment" rows="10" cols="100"
style="font:100% Arial;">Enter your comment in
here</textarea><br />
</div>
<div align="center" style="background-color:#DBE0F5; padding:3px;
font:12px arial;">
<input type="button" id="submit" value=" Send "
onmouseover="testform()" onclick="sendform()" />
<input type="reset" id="reset" value=" Clear "/>
</div>
</form>