Sorry I ran into another problem, I did some searches on this forum and found one post that gave some examples, but I'm unable to get it to work below is the code I have, I will highlight the parts that are giving my trouble in Red.
<html>
<head>
<link rel="stylesheet" href=http://codingforums.com/archive/index.php/"/cco/include/umn.css" type="text/css">
<style type="text/css"><!--
@import url(/cco/include/umnglobalbkgimg.css);
--></style>
<title>Service Center Mass Changes</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
window['pageid']='email';
</script>
<?
require_once ("/home/cco/web-docs/include/left_scr.txt")
?>
<script language="javascript" type="text/javascript" src=http://codingforums.com/archive/index.php/"datetimepicker.js"></script>
<script language="JavaScript" type="text/javascript">
function validate(frm) {
if(frm.sc_description.value=="") {
alert("Please Fill In The Description Field")
frm.sc_description.focus();
return(false);
}
else if(frm.sc_justification.value=="") {
alert("Please Fill In The Instructions Field")
frm.sc_justification.focus();
return(false);
}
else if(frm.sc_backoutmethod.value=="") {
alert("Please Fill In The Recovery Procedures Field")
frm.sc_backoutmethod.focus();
return(false);
}
else if(frm.StartDate.value=="") {
alert("Please Fill In The Start Date Field")
frm.StartDate.focus();
return(false);
}
else if(frm.EndDate.value=="") {
alert("Please Fill In The End Date Field")
frm.EndDate.focus();
return(false);
}
else if(frm.StartDate.value > frm.EndDate.value) {
alert("Start Date Is Not Less Then End Date")
frm.StartDate.focus();
return(false);
}
var chks = document.SCupdate.elements['server[]'];
var hasChecked = true;
for (var i=0;i<chks.length;i++){
if (chks[i].checked){
hasChecked = false;
break;
}
}
if (hasChecked=="true"){
alert("Please select at least one.");
chks[0].focus();
return false;
}return(true);
}
</script>
</head>
<body bgcolor="#FFFFFF" onLoad="setbold(window.pageid);">
<?
require_once ("/home/cco/web-docs/include/header_nav.txt")
?>
<?
require_once ("/home/cco/web-docs/include/header.txt")
?>
<?
require_once ("/home/cco/web-docs/include/title.txt")
?>
<!-- BEGIN BODY -->
<table width="760" border="0" cellpadding="0" cellspacing="0">
<tr>
<?
require_once ("/home/cco/web-docs/include/left_nav.txt")
?>
<td width="569" valign="top">
<td width="569" valign="top"><table width="569" border="0" cellpadding="0" cellspacing="0">
</table>
<table width="569" border="0" cellpadding="0" cellspacing="10">
<tr>
<td valign="top">
<!-- START ADDING HERE -->
<h3 align="center">Service Center Mass Changes</h3>
<centeR>
<table border="1" width="35%">
<form name="SCupdate" method="GET" action="UpdateView.php">
<tr>
<td>Planned Start </td>
<td><input id="StartDate" name="StartDate" type="text" size="20"><a href="javascript:NewCal('StartDate','mmddyyyy',true,24)"><img src=http://codingforums.com/archive/index.php/http://codingforums.com/archive/index.php/"images/cal.gif" width="16" height="16" border="0" alt="StartDate"></a>
</td>
<tr>
<td>Planned End</td>
<td><input id="EndDate" name="EndDate" type="text" size="20"><a href="javascript:NewCal('EndDate','mmddyyyy',true,24)"><img src=http://codingforums.com/archive/index.php/http://codingforums.com/archive/index.php/"images/cal.gif" width="16" height="16" border="0" alt="EndDate"></a>
</td>
</tr>
<tr>
<td>Category</td>
<td>Description</td>
</tr>
<tr>
<td>
<select name="sc_category">
<option value="c.Facilities.">c.Facilities.
<option value="c.Hardware.">c.Hardware.
<option value="c.Network.">c.Network.
<option value="c.Software.">c.Software.
</select>
</td>
<td><input type="text" name="sc_description"></td>
</tr>
<tr>
<td>Instructions</td>
<td>Recovery Procedures</td>
<tr>
<td><input type="text" name="sc_justification"></td>
<td><input type="text" name="sc_backoutmethod"></td>
</tr>
<tr>
<td>Component</td>
<td>Reason</td>
<tr>
<td><input type="text" name="sc_component"></td>
<td>
<select name="sc_reason">
<option value="Capacity">Capacity
<option value="Conversion">Conversion
<option value="Customer Request">Customer Request
<option value="Disaster Recovery Test">Disaster Recovery Test
<option value="Legal">Legal
<option value="New">New
<option value="Performance">Performance
<option value="Problem Resolution">Problem Resolution
<option value="Project">Project
<option value="Scheduled Maintenance">Scheduled Maintenance
<option value="Security">Security
</select>
</tr>
<tr>
<td align="center" colspan="2">Servers
</tr>
<tr>
<td align="left" colspan="2">
<?
$filename=$_GET['FileName'];
$fp = fopen($filename,"r");
while (!feof($fp))
{
$line = fgets($fp, 4096);
if ($line != null)
{
print "<input type=checkbox name=server[] value=$line>$line";
}
}
fclose($fp);
?>
</td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" value="Submit" onClick="return validate(SCupdate)"></td>
</tr>
</form>
</table>
<h2 align="center">This process could take a few minutes. Please do not hit the refresh or close this window until you get the confirmation that your Change requests have been opened.</h2>
<!-- END ADDING HERE -->
</td>
</tr>
</table>
<!-- END BODY CONTENT -->
</td>
</tr>
</table>
<!-- END BODY -->
<?
require_once ("/home/cco/web-docs/include/footer.txt")
?>
<?
// outputs e.g. somefile.txt was last modified: December 29 2002 22:16:23.
if (file_exists($filename)) {
echo " " . date ("F d Y H:i:s.", filemtime($filename));
}
?>
<!--continuation of footer-->
<!--#config timefmt="%B %d, %Y"--><!--#ECHO VAR="LAST_MODIFIED"-->
</div></td>
</tr>
</table></td>
</tr>
</table>
<!--end of footer-->
</body>
</html>
Thanks for all the help
Here is a link to the page = URL = http://www1.umn.edu/cco/test/JimTest/
I fixed it so NetScape and Mozilla will work.
vwphillips
03-16-2006, 11:09 PM
use
var chks = document.getElementsByName('server[]');
names with '[]' are illegal but the above will provide an array that can be used for validation
there are a number examples on
http://www.vicsjavascripts.org.uk/FormCompendium/FormCompendium.htm
that address '[]' issues
Well I don't think that will change the situation, as in theory is the same thing. I guess rather that the created html element must be standard created, with attributes' values double quoted.
print '<input type="checkbox" name="server[]" value="$line>$line"';
or something like that. The moment when, as vwphillips said, name (or id) have "illegal" special characters, the quotes are required.
vwphillips
03-17-2006, 01:36 PM
use
var chks = document.getElementsByName('server[]');
Well I don't think that will change the situation,
to demonstrate
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--
function validate(frm){
var chks = document.getElementsByName('server[]');
var hasChecked = true;
for (var i=0;i<chks.length;i++){
if (chks[i].checked){
hasChecked = false;
break;
}
}
if (hasChecked){
alert("Please select at least one.");
chks[0].focus();
return false;
}
return true;
}
//-->
</script>
</head>
<body>
<form>
<input type="radio" name="server[]">
<input type="radio" name="server[]">
<input type="button" value="Verify" onclick="validate(this.form);" >
</form>
</body>
</html>