Click to See Complete Forum and Search --> : almost there, not quite


geuis
02-10-2003, 07:36 PM
In this code, clicking on the button generates a new email w/ certain info already populating the field. What I want to do is make it so that when one of the selections from the drop-down list is selected, it will change the subject to the value of that option. So, clicking on Dropped Call will make an email that has Dropped Call as its subject.

<html>
<head>
<title>MAILTO</title>
<script type="text/javascript">

function email()
{
var subject = "This email is being sent using a function by variables"
var body = "This email was generated at ["+new Date()+"]";
location.replace("MAILTO:Someone@somewhere.com="+subject+"&body="+body+";");
return true;
}

function email2(stuff)
{
alert(stuff)
}

</script>
</head>

<body bgcolor="#FFFFFF">

<form name="mainForm">
<input type="button" value="Dropped Call" onclick="email()">

<select onchange="email2()">
<option value="Dropped Call">Dropped Call
<option value="Misdirected">Misdirected
</select>

</form>


</body>
</html>

geuis
02-11-2003, 08:00 AM
ja, I had missed that bit. But still, I'm not sure how to incorporate the drop-down menu so that it will trigger the function to generate the new email.

cyberade
02-11-2003, 09:38 AM
Try this (Note, this also causes the message on the button to reflect what was selected):<html>
<head>
<title>MAILTO</title>
<script type="text/javascript">

function email()
{
var cause = document.forms[0].reason.options[document.forms[0].reason.selectedIndex].text

var subject = cause+": This email is being sent using a function by variables"
var body = "This email was generated at ["+new Date()+"]";
location.replace("MAILTO:Someone@somewhere.com?subject="+subject+"&body="+body+";");
return true;
}

function email2()
{
document.forms[0].button1.value = document.forms[0].reason.options[document.forms[0].reason.selectedIndex].text
}

</script>
</head>

<body bgcolor="#FFFFFF">

<form name="mainForm">
<input type="button" name="button1" value="Dropped Call" onclick="email()">

<select name="reason" onchange="email2()">
<option value="Dropped Call">Dropped Call
<option value="Misdirected">Misdirected
</select>

</form>


</body>
</html>

geuis
02-11-2003, 11:09 AM
Cool. Works perfectly. Thank you.