TotallyClueless
04-23-2004, 05:13 PM
I am trying to create a form to allow people to submit support requests using a web form (before you ask I have access to CGI so am left with no alternative but to do it this way). Anyway, issue is that when the form is validated, when you acknowledge the alert, the for reloads/clears. How do I stop this from occuring?
Thanks for any ideas .....
<html>
<head>
<form name="servicerequest">
<script language="JavaScript">
function sendtheMail() {
var frm = document.forms["servicerequest"];
if (document.forms[0].Urgency.value == "") {
alert("No urgency has been specified!");
return false;
}
if (document.forms[0].Product.value == "") {
alert("No product has been specified!");
return false;
}
if (document.forms[0].Country.value == "") {
alert("No member firm/country has been specified!");
return false;
}
if (document.forms[0].Office.value == "") {
alert("No office has been specified!");
return false;
}
if (document.forms[0].PrimaryContact.value == "") {
alert("No primary contact has been specified!");
return false;
}
if (document.forms[0].PCPhone.value == "") {
alert("The primary contact's office phone number has not been entered!");
return false;
}
if (document.forms[0].PCMobile.value == "") {
alert("The primary contact's mobile/cell phone number has not been entered!");
return false;
}
if (document.forms[0].message.value == "") {
alert("No details have been entered!");
return false;
}
document.forms[0].action = "mailto:totallyclueless@abc.com" +
"?subject=" +
document.forms[0].Urgency.value;
alert("You may now see a message informing you that this program will submit the form via e-mail, then another message confirming that you wish to continue. Please select OK, then Yes when prompted to allow the submission to proceed.");
return true;
}
</script>
</head>
<body bgcolor="navy" text="white">
<form method="post" enctype="text/plain">
<p><b><font size="5">Service Request Form</font></b></p>
<table border="0">
<tr>
<td align="right">
<div align="left">
<b>Urgency:</b></div>
</td>
<td><select name="Urgency" size="1" tabindex="1">
<option value="High">High</option>
<option value="Medium">Medium</option>
<option selected value="Normal">Normal</option>
</select></td>
<td><b>Product</b>:*</td>
<td><select name="Product" size="1" tabindex="2">
<option value="Active Directory">Active Directory</option>
<option value="Exchange">Exchange</option>
<option value="Virus">Virus</option>
</select></td>
</tr>
<tr>
<td align="right">
<div align="left">
<b>Country:*</b></div>
</td>
<td><select name="Country" size="1" tabindex="3">
<option value="Albania">Albania</option>
<option value="Angola">Angola</option>
</select></td>
<td><b>Office:*</b></td>
<td><input type="text" name="Office" size="27" tabindex="4" border="0"></td>
</tr>
<tr>
<td align="right">
<div align="left">
<b>Primary Contact:*</b></div>
</td>
<td><input type="text" name="PrimaryContact" size="34" tabindex="5" border="0"></td>
<td><b>Phone:*</b></td>
<td><input type="text" name="PCPhone" size="27" tabindex="6" border="0"></td>
</tr>
<tr>
<td align="right"></td>
<td></td>
<td><b>Mobile/Cell:*</b></td>
<td><input type="text" name="PCMobile" size="27" tabindex="7" border="0"></td>
</tr>
<tr>
<td align="right"></td>
</tr>
<tr>
<td align="right">
<div align="left">
<b>Secondary Contact: </b></div>
</td>
<td><input type="text" name="SecondaryContact" size="34" tabindex="8" border="0"></td>
<td><b>Phone:</b></td>
<td><input type="text" name="SCPhone" size="27" tabindex="9" border="0"></td>
</tr>
<tr>
<td align="right"></td>
<td></td>
<td><b>Mobile/Cell</b></td>
<td><input type="text" name="SCMobile" size="27" tabindex="10" border="0"></td>
</tr>
<tr valign="top">
<td align="right">
<p align="left"><b>Details:*</b></p>
<div align="left">
<p>Please provide as much detail as possible including steps taken to isolate or resolve.</p>
</div>
</td>
<td colspan="3"><textarea name="message" rows="11" cols="77" tabindex="11"></textarea></td>
</tr>
<tr valign="top">
<td align="right">
<div align="left">
<b>Notes:</b></div>
</td>
<td colspan="3">
<ul>
<li>All fields marked with * are mandatory
</ul>
</td>
</tr>
</table>
<hr>
<input onclick="sendtheMail()" type="submit" value="Submit" tabindex="12"> <input type="reset" value="Clear">
</form>
</form>
</body>
</html>
Thanks for any ideas .....
<html>
<head>
<form name="servicerequest">
<script language="JavaScript">
function sendtheMail() {
var frm = document.forms["servicerequest"];
if (document.forms[0].Urgency.value == "") {
alert("No urgency has been specified!");
return false;
}
if (document.forms[0].Product.value == "") {
alert("No product has been specified!");
return false;
}
if (document.forms[0].Country.value == "") {
alert("No member firm/country has been specified!");
return false;
}
if (document.forms[0].Office.value == "") {
alert("No office has been specified!");
return false;
}
if (document.forms[0].PrimaryContact.value == "") {
alert("No primary contact has been specified!");
return false;
}
if (document.forms[0].PCPhone.value == "") {
alert("The primary contact's office phone number has not been entered!");
return false;
}
if (document.forms[0].PCMobile.value == "") {
alert("The primary contact's mobile/cell phone number has not been entered!");
return false;
}
if (document.forms[0].message.value == "") {
alert("No details have been entered!");
return false;
}
document.forms[0].action = "mailto:totallyclueless@abc.com" +
"?subject=" +
document.forms[0].Urgency.value;
alert("You may now see a message informing you that this program will submit the form via e-mail, then another message confirming that you wish to continue. Please select OK, then Yes when prompted to allow the submission to proceed.");
return true;
}
</script>
</head>
<body bgcolor="navy" text="white">
<form method="post" enctype="text/plain">
<p><b><font size="5">Service Request Form</font></b></p>
<table border="0">
<tr>
<td align="right">
<div align="left">
<b>Urgency:</b></div>
</td>
<td><select name="Urgency" size="1" tabindex="1">
<option value="High">High</option>
<option value="Medium">Medium</option>
<option selected value="Normal">Normal</option>
</select></td>
<td><b>Product</b>:*</td>
<td><select name="Product" size="1" tabindex="2">
<option value="Active Directory">Active Directory</option>
<option value="Exchange">Exchange</option>
<option value="Virus">Virus</option>
</select></td>
</tr>
<tr>
<td align="right">
<div align="left">
<b>Country:*</b></div>
</td>
<td><select name="Country" size="1" tabindex="3">
<option value="Albania">Albania</option>
<option value="Angola">Angola</option>
</select></td>
<td><b>Office:*</b></td>
<td><input type="text" name="Office" size="27" tabindex="4" border="0"></td>
</tr>
<tr>
<td align="right">
<div align="left">
<b>Primary Contact:*</b></div>
</td>
<td><input type="text" name="PrimaryContact" size="34" tabindex="5" border="0"></td>
<td><b>Phone:*</b></td>
<td><input type="text" name="PCPhone" size="27" tabindex="6" border="0"></td>
</tr>
<tr>
<td align="right"></td>
<td></td>
<td><b>Mobile/Cell:*</b></td>
<td><input type="text" name="PCMobile" size="27" tabindex="7" border="0"></td>
</tr>
<tr>
<td align="right"></td>
</tr>
<tr>
<td align="right">
<div align="left">
<b>Secondary Contact: </b></div>
</td>
<td><input type="text" name="SecondaryContact" size="34" tabindex="8" border="0"></td>
<td><b>Phone:</b></td>
<td><input type="text" name="SCPhone" size="27" tabindex="9" border="0"></td>
</tr>
<tr>
<td align="right"></td>
<td></td>
<td><b>Mobile/Cell</b></td>
<td><input type="text" name="SCMobile" size="27" tabindex="10" border="0"></td>
</tr>
<tr valign="top">
<td align="right">
<p align="left"><b>Details:*</b></p>
<div align="left">
<p>Please provide as much detail as possible including steps taken to isolate or resolve.</p>
</div>
</td>
<td colspan="3"><textarea name="message" rows="11" cols="77" tabindex="11"></textarea></td>
</tr>
<tr valign="top">
<td align="right">
<div align="left">
<b>Notes:</b></div>
</td>
<td colspan="3">
<ul>
<li>All fields marked with * are mandatory
</ul>
</td>
</tr>
</table>
<hr>
<input onclick="sendtheMail()" type="submit" value="Submit" tabindex="12"> <input type="reset" value="Clear">
</form>
</form>
</body>
</html>