Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2003
    Location
    Australia
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problem when checking submit type...

    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>

    Last edited by jaeman; 12-24-2003 at 04:08 AM.

  • #2
    New to the CF scene
    Join Date
    Dec 2003
    Location
    Australia
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Almost there...

    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

  • #3
    New to the CF scene
    Join Date
    Dec 2003
    Location
    Australia
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changed 1 to submit & 1 to button...

    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •