whammond
07-29-2002, 06:21 PM
Ok, guys...I recieved a lil script on here like last week. It made supurb since to me, but I somehow can not get it to work within my page. The error I recieve is a "(function name) not defined" error. Heres my page:
<html>
<head>
<script src='../functions.js' language=JavaScript></script>
<link rel=stylesheet type=text/css href='template.css'>
<title>New Project</title>
<script language="text/javascript">
function checkrequired(which){ //open of function
var pass=true;
if(document.images){ //open first if
for(i=0;i<which.length;i++){ //open for loop
var tempobj=which.elements[i];
if(tempobj.name.substring(0,8)=="required"){ //open third if
if(((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)) { //open fourth if
pass=false;
break;
} //close fourth if
} //close third if
} //close for loop
} //close first if
if(!pass){
alert("One or more of the required elements are not completed. Please complete them, then submit again!");
return false;
}
else
return true;
} //close of function
</script>
</head>
<body vspace=0>
<table width=630 align=left>
<tr height=20><td width="622"> </td>
</tr><tr>
<td width="622">
<!-- code goes here -->
<form method="POST" action="projecthomepage.html" name="date" onSubmit="checkrequired(this)">
<table class=table align="center" cellspacing=0 width=553 border=0>
<tr>
<td class=outTableTitle colspan="2">
<h1><b>Add New Project</h1></b>
</td>
</tr><tr>
<td class=outTableHead>Sponsor First Name:</td>
<td><input type="text" name="requiredf_firstName"><font color="red">*</font></td>
</tr><tr> <!--LINE 50-->
<td class=outTableHead>Sponsor Last Name:</td>
<td><input type="text" name="requiredf_lastName"><font color="red">*</font></td>
</tr><tr>
<td class=outTableHead>Project Description:</td>
<td><input type="text" name="requiredf_projectDescription" size="45"><font color="red">*</font></td>
</tr><tr>
<td class=outTableHead>Project Request Date:</td>
<td><input type="text" name="f_date" size="10"><i>(MM/DD/YYYY)</i></td>
</tr><tr>
<td class=outTableHead>Project Start Date:</td>
<td><input type="text" name="f_projectStartDate" size="10"><i>(MM/DD/YYYY)</i></td>
</tr><tr>
<td class=outTableHead>Project Target Date:</td>
<td><input type="text" name="f_projectTargetDate" size="10"><i>(MM/DD/YYYY)</i></td>
</tr><tr>
<td class=outTableHead>Project Manager:</td>
<td><select name="projectManager">
<option>Suzanne White
<option>Valeri Battcher
<option>Walter Hammond
<option>Thomas Stanton
<option>Bridget Klare
</select></td>
</tr><tr>
<td class=outTableHead>Cost Center:</td>
<td><input type="text" name="f_costCenter"></td>
</tr><tr>
<td class=outTableHead>Priority Level:</td>
<td><input type="text" name="f_priorityLevel"> (High,Medium,Low)</td>
</tr><tr>
<td class=outTableHead>Status:</td>
<td><input type="text" name="f_status" value="New Project"></td>
</tr><tr>
<td class=outTableHead>Project id:</td>
<td><input type="text" name="requiredf_id"><font color="red">*</font></td>
</tr>
</table>
<br><br>
<center><input type="submit" name="newproject" value="Create Project"></center>
</form>
<!--code ends here -->
<td/>
<tr>
<td width="622">
</td>
</tr>
<tr height=300>
<td width="622">
</td></tr></table>
</body>
</html>
------------------------------------------------------------------------------------
Thank you for all responses in advance.
<html>
<head>
<script src='../functions.js' language=JavaScript></script>
<link rel=stylesheet type=text/css href='template.css'>
<title>New Project</title>
<script language="text/javascript">
function checkrequired(which){ //open of function
var pass=true;
if(document.images){ //open first if
for(i=0;i<which.length;i++){ //open for loop
var tempobj=which.elements[i];
if(tempobj.name.substring(0,8)=="required"){ //open third if
if(((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)) { //open fourth if
pass=false;
break;
} //close fourth if
} //close third if
} //close for loop
} //close first if
if(!pass){
alert("One or more of the required elements are not completed. Please complete them, then submit again!");
return false;
}
else
return true;
} //close of function
</script>
</head>
<body vspace=0>
<table width=630 align=left>
<tr height=20><td width="622"> </td>
</tr><tr>
<td width="622">
<!-- code goes here -->
<form method="POST" action="projecthomepage.html" name="date" onSubmit="checkrequired(this)">
<table class=table align="center" cellspacing=0 width=553 border=0>
<tr>
<td class=outTableTitle colspan="2">
<h1><b>Add New Project</h1></b>
</td>
</tr><tr>
<td class=outTableHead>Sponsor First Name:</td>
<td><input type="text" name="requiredf_firstName"><font color="red">*</font></td>
</tr><tr> <!--LINE 50-->
<td class=outTableHead>Sponsor Last Name:</td>
<td><input type="text" name="requiredf_lastName"><font color="red">*</font></td>
</tr><tr>
<td class=outTableHead>Project Description:</td>
<td><input type="text" name="requiredf_projectDescription" size="45"><font color="red">*</font></td>
</tr><tr>
<td class=outTableHead>Project Request Date:</td>
<td><input type="text" name="f_date" size="10"><i>(MM/DD/YYYY)</i></td>
</tr><tr>
<td class=outTableHead>Project Start Date:</td>
<td><input type="text" name="f_projectStartDate" size="10"><i>(MM/DD/YYYY)</i></td>
</tr><tr>
<td class=outTableHead>Project Target Date:</td>
<td><input type="text" name="f_projectTargetDate" size="10"><i>(MM/DD/YYYY)</i></td>
</tr><tr>
<td class=outTableHead>Project Manager:</td>
<td><select name="projectManager">
<option>Suzanne White
<option>Valeri Battcher
<option>Walter Hammond
<option>Thomas Stanton
<option>Bridget Klare
</select></td>
</tr><tr>
<td class=outTableHead>Cost Center:</td>
<td><input type="text" name="f_costCenter"></td>
</tr><tr>
<td class=outTableHead>Priority Level:</td>
<td><input type="text" name="f_priorityLevel"> (High,Medium,Low)</td>
</tr><tr>
<td class=outTableHead>Status:</td>
<td><input type="text" name="f_status" value="New Project"></td>
</tr><tr>
<td class=outTableHead>Project id:</td>
<td><input type="text" name="requiredf_id"><font color="red">*</font></td>
</tr>
</table>
<br><br>
<center><input type="submit" name="newproject" value="Create Project"></center>
</form>
<!--code ends here -->
<td/>
<tr>
<td width="622">
</td>
</tr>
<tr height=300>
<td width="622">
</td></tr></table>
</body>
</html>
------------------------------------------------------------------------------------
Thank you for all responses in advance.