Ok, the validation is working, but it is putting the option value as 1,2,or 3 in the subject of the email being sent. I want it to use my function "findsub" to replace the numeric value with the corresponding subject. I also want to be able to change the recipient of the email as the subject changes. If anyone can help I will be very grateful. Thanks for the help!
Here is my updated code:
<HTML>
<HEAD>
<BASE TARGET="FRAME2">
<TITLE> Allons Church of Christ </TITLE>
<style type="text/css">
</style>
<Script language="JavaScript" type="text/javascript">
function validate ()
{
if (document.myform.sub.value == "")
{
alert('You must select a subject');
return false;
}
else if (document.myform.realname.value == "")
{
alert('Name cannot be blank');
return false;
}
else if (document.myform.email.value == "")
{
alert('Your email address is required');
return false;
}
else if (document.myform.question.value == "")
{
alert('You left the question box blank. Did you have a question?');
return false;
}
document.myform.subject.value=document.myform.sub.value;
return true;
}
function findsub ()
{
if (document.myform.subject.value == "1")
{
document.myform.subject.value = "Biblical Inquiry";
}
else if (document.myform.subject.value =="2")
{
document.myform.subject.value = "Benevolence Inquiry";
}
else if (document.myform.subject.value =="3")
{
document.myform.subject.value = "Website Inquiry";
}
}
//-->
</Script>
</HEAD>
<BODY>
<BR><BR><BR>
<FORM name="myform" id="myform" ACTION="/cgi-sys/FormMail.cgi" METHOD="POST"
onsubmit="return validate ()">
<table align="center" border="2" cellpadding="10" frame="box" rules="none">
<tr>
<td>Your Name </td>
<td>
<input type="text" size="30" name="realname" />
</td>
</tr>
<tr>
<td> Your e-mail address </td>
<td>
<INPUT TYPE="text" size="20" NAME="email" />
</td</tr>
<tr>
<td> Subject </td>
<td>
<Select name = "sub" id="sub">
<option value=""> Please select one... </option>
<option value="1"> Biblical Inquiry </option>
<option value="2"> Benevolence Inquiry </option>
<option value="3"> Website Inquiry </select> </option>
</select>
</td></tr>
<tr>
<td> Question </td>
<td>
<textarea name="question" id="question" cols="40" rows="10">
</textarea> </td></tr>
<tr align="center">
<td colspan="2">
<hr width="100% align="center"> </td></tr>
<tr>
<td colspan="2">
<INPUT TYPE= submit value="Submit Question" />
<input type= reset value="Reset Form" />
</td> </tr>
</table>
<input type=hidden name="subject" value = 'document.myform.sub.value'>
<input type=hidden name="recipient" value ="webmaster@allonschurch.org">
<input type=hidden name="env_report" value ="REMOTE_HOST,REMOTE_ADDR,HTTP_USER_AGENT">
</FORM>
</body>
</html>