...

View Full Version : Problem when checking submit type...



jaeman
12-24-2003, 02:04 AM
Hey there, The problem i'm having is that when the script checks the "add item" submit button it should check to see if the form fields are empty or not then proccess the form or focus on the empty field, The "finished" submit button should bypass the empty field checks & return true going back to the main menu WHICH it is not doing..! jaeman




<head>

<script language="Javascript" type="text/javascript">
<!-- Confirm
function checkForm(addFORM) {


if(addFORM.action.value == "Finished") {
return true;
}
if(addFORM.action.value == "Add Item") {

if(addFORM.item.value == "") {
alert("You must enter an Item Name..!");
addFORM.item.focus();
return false;
}
if(addFORM.catagory.value == "Pick a Catagory") {
alert("You must choose a Catagory..!");
addFORM.catagory.focus();
return false;
}
if(addFORM.info.value == "") {
alert("You must enter some Item Info..!");
addFORM.info.focus();
return false;
}
if(addFORM.upfile.value == "") {
alert("You must enter a Photo File..!");
addFORM.upfile.focus();
return false;
}

}

return true;
}
// End Confirm -->
</script>

</head>

jaeman
12-26-2003, 02:15 AM
The script seems to submit but ends with an internal error, Can't seem to find the problem...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>

<title>$title: ADD NEW ITEM</title>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

<script language="Javascript" type="text/javascript">
<!-- Begin Submit Check & Confirm
function endForm(endFORM) {
endFORM.submit();
return true;
}
function addForm(addFORM) {
if(addFORM.item.value == "") {
alert("You must enter an Item Name..!");
addFORM.item.focus();
return false;
}
if(addFORM.catagory.value == "Pick a Catagory") {
alert("You must choose a Catagory..!");
addFORM.catagory.focus();
return false;
}
if(addFORM.info.value == "") {
alert("You must enter some Item Info..!");
addFORM.info.focus();
return false;
}
if(addFORM.upfile.value == "") {
alert("You must enter a Photo File..!");
addFORM.upfile.focus();
return false;
}
addFORM.submit();
return true;
}
// End Submit Check & Confirm -->
</script>

</head>

<body>
<form name="update" action="$fname?UPDATE" method="post" enctype="multipart/form-data">
<H3>$title: Update</H3>
<table style="$table1">
<tr>
<td>Enter item name<br><input type="text" name="item" size="30"><br></td>
</tr>

<tr>
<td>
Enter item catagory
<br>

<select name="catagory" size="1">
<option value="Pick a Catagory">Pick a Catagory</option>
<option value="Clothing">Clothing</option>
<option value="Electrical">Electrical</option>
<option value="Furniture">Furniture</option>
<option value="Hardware">Hardware</option>
<option value="Kitchen ware">Kitchen Ware</option>
<option value="Misc">Misc</option>
<option value="Sports Equipment">Sports Equipment</option>
<option value="Toys">Toys</option>
</select>

<br>
</td>
</tr>

<tr>
<td>Enter Item Info<br><textarea name="info" cols="40" rows="5"></textarea><br></td>
</tr>

<tr>
<td>Enter Item Photo<br><input type="file" name="upfile"><br></td>
</tr>

<tr>
<td>
<div align="center">
<br><br>
<input type="button" name="action" value="Add Item" onClick="return addForm(update)">
&nbsp;&nbsp;
<input type="reset" value="Reset">
&nbsp;&nbsp;
<input type="button" name="action" value="Finished" onClick="return endForm(update)">
</div>
</td>
</tr>
</table>
</form>
</body>

</html>


EOF

jaeman
12-26-2003, 05:45 AM
Well finally got around what i was trying to do, I have the submit button checking form fields & the finish button going striaght to the menu location...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>

<title>$title: ADD NEW ITEM</title>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">

<script language="Javascript" type="text/javascript">
<!-- Begin Submit Check & Confirm
function addForm(addFORM) {
if(addFORM.item.value == "") {
alert("You must enter an Item Name..!");
addFORM.item.focus();
return false;
}
if(addFORM.catagory.value == "Pick a Catagory") {
alert("You must choose a Catagory..!");
addFORM.catagory.focus();
return false;
}
if(addFORM.info.value == "") {
alert("You must enter some Item Info..!");
addFORM.info.focus();
return false;
}
if(addFORM.upfile.value == "") {
alert("You must enter a Photo of the Item..!");
addFORM.upfile.focus();
return false;
}
return true;
}
// End Submit Check & Confirm -->
</script>

</head>

<body>
<form action="$fname?UPDATE" onSubmit="return addForm(this);" method="post" enctype="multipart/form-data">
<H3>$title: Update</H3>
<table style="$table1">
<tr>
<td>Enter item name<br><input type="text" name="item" size="30"><br></td>
</tr>

<tr>
<td>
Enter item catagory
<br>
SFORM

GetCATAGORY();

print <<FFORM;
<br>
</td>
</tr>

<tr>
<td>Enter Item Info<br><textarea name="info" cols="40" rows="5"></textarea><br></td>
</tr>

<tr>
<td>Enter Item Photo<br><input type="file" name="upfile"><br></td>
</tr>

<tr>
<td>
<div align="center">
<br><br>
<input type="submit" name="action" value="Add Item">
&nbsp;&nbsp;
<input type="reset" value="Reset">
&nbsp;&nbsp;
<input type="button" name="action" value="Finished" onClick="javascript:location.href='dataform.cgi';">
</div>
</td>
</tr>
</table>
</form>
</body>

</html>


EOF



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum