tripwater
04-23-2003, 11:38 AM
I have a form that I validate (ALL fields are required)
I have everything working (validating) except the droplist "alerttype". I have the default selected value= "" so that it is empty on appearance.
Here is my code :
<SCRIPT LANGUAGE=\"JavaScript\">
function TheFormCheck()
{
if (document.addalert.alert.value == \"\" || document.addalert.details.value == \"\")
{
alert(\"Please fill in the required blue fields to continue.\");
document.addalert.alert.focus();
return false;
}
else return true;
}
</script>
<a href=../support/adminnetstatus.php>Back to Network Status and Alert Types</a><p><p>
<form name=\"addalert\" method=\"post\" action=\"../admin/alertsubmit.php\" onSubmit=\"return TheFormCheck()\">
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">
<tr>
<td colspan=4>
Please fill in the fields below and click <b>Submit</b><p>
<b><span style=color:blue>All Fields Are Required</span></b><p>
</td>
</tr>
<tr>
<td width=25%>
Alert Type :
</td>
<td>
<Select name=alerttype>
<option value=\"\" selected>";
//here we loop through and build a list of alert types and set the
//selected to the current type that is associated with the alert the user
//selected.
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$row = @mysql_fetch_array($result,MYSQL_ASSOC);
$value .= '<Option value="'.$row["Type"].'">'.$row["AlertCategory"];
}
$value .="</select>
</td>
<td width=15%>
Select Status :
</td>
<td>
<select name=status>
<option value=\"Active\" selected>Active
<option value=\"Pending\">Pending
<option value=\"Closed\">Closed
</select>
</td>
</tr>
<tr>
<td colspan=4>
<p><p>
<td>
</tr>
<tr>
<td>
Alert Title :
</td>
<td colspan=2>
<input type=text name=alert size=50 maxlength=100 value=\"\">
</td>
</tr>
<tr>
<td colspan=4>
<p><p>
<td>
</tr>
<tr valign=top>
<td valign=top>
Alert Details :
</td>
<td colspan=2>
<textarea name=details cols=\"60\" rows=\"15\" wrap=\"VIRTUAL\" ></textarea>
</td>
<td>
<input type=radio name=proctype checked=true value=0>Add<br>
</td>
</tr>
<tr>
<td colspan=3 align=right>
<input type=submit name=submit value=Submit>
<td>
</tr>
</table></form>
What do I need to do to make sure that they have selected something from my droplist alerttype?
I have everything working (validating) except the droplist "alerttype". I have the default selected value= "" so that it is empty on appearance.
Here is my code :
<SCRIPT LANGUAGE=\"JavaScript\">
function TheFormCheck()
{
if (document.addalert.alert.value == \"\" || document.addalert.details.value == \"\")
{
alert(\"Please fill in the required blue fields to continue.\");
document.addalert.alert.focus();
return false;
}
else return true;
}
</script>
<a href=../support/adminnetstatus.php>Back to Network Status and Alert Types</a><p><p>
<form name=\"addalert\" method=\"post\" action=\"../admin/alertsubmit.php\" onSubmit=\"return TheFormCheck()\">
<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\">
<tr>
<td colspan=4>
Please fill in the fields below and click <b>Submit</b><p>
<b><span style=color:blue>All Fields Are Required</span></b><p>
</td>
</tr>
<tr>
<td width=25%>
Alert Type :
</td>
<td>
<Select name=alerttype>
<option value=\"\" selected>";
//here we loop through and build a list of alert types and set the
//selected to the current type that is associated with the alert the user
//selected.
for ($i = 0; $i < mysql_num_rows($result); $i++)
{
$row = @mysql_fetch_array($result,MYSQL_ASSOC);
$value .= '<Option value="'.$row["Type"].'">'.$row["AlertCategory"];
}
$value .="</select>
</td>
<td width=15%>
Select Status :
</td>
<td>
<select name=status>
<option value=\"Active\" selected>Active
<option value=\"Pending\">Pending
<option value=\"Closed\">Closed
</select>
</td>
</tr>
<tr>
<td colspan=4>
<p><p>
<td>
</tr>
<tr>
<td>
Alert Title :
</td>
<td colspan=2>
<input type=text name=alert size=50 maxlength=100 value=\"\">
</td>
</tr>
<tr>
<td colspan=4>
<p><p>
<td>
</tr>
<tr valign=top>
<td valign=top>
Alert Details :
</td>
<td colspan=2>
<textarea name=details cols=\"60\" rows=\"15\" wrap=\"VIRTUAL\" ></textarea>
</td>
<td>
<input type=radio name=proctype checked=true value=0>Add<br>
</td>
</tr>
<tr>
<td colspan=3 align=right>
<input type=submit name=submit value=Submit>
<td>
</tr>
</table></form>
What do I need to do to make sure that they have selected something from my droplist alerttype?