Results 1 to 1 of 1

Thread: JS runtime error - Object expected

  1. #1
    sjsanjuan Guest

    JS runtime error - Object expected

    Hi Guys,

    I'm having the same problem. My program works fine in Firefox but when I tried it in IE8 an error message pops out, "Runtime error: Object expected".

    The error message comes out whenever I add or delete a category. Here's the code:

    }
    function doDelete(id) {
    if (window.confirm("Proceed with delete?") == true) {
    x_doDelete(id,Callback); ----> so as this is as well
    }

    function doAddEdit() {
    objID = document.getElementById("CID");
    objDescription = document.getElementById("CName");

    x_doAddEdit(objID.value,objDescription.value,Callback); ----> this is the error
    return false;
    }


    Here's the full code:


    PHP Code:
    <?php
    require_once("../connection.php");
    require_once(
    "session.php");
    require_once(
    "classes/UserAccessManager.php");
    require_once(
    "Sajax.php");
    require_once(
    "classes/Pager.php");

    $objUserAccessManager = new UserAccessManager();
    $objUserAccessManager->setAccess("Administrators");
    $granted $objUserAccessManager->checkAccess($_SESSION['UserID'], $_SESSION['UGDescription']);
    if (!
    $granted) {
        
    header("Location: index.php?status=2");
        exit();
    }
    function 
    checkRecord ($description) {
        
    $query sprintf("SELECT * FROM categories WHERE CName LIKE '%s'",$description);
        
    $result mysql_query($query) or die(mysql_error());
        if (
    mysql_num_rows($result) > 0) {
            return 
    true;
        }
    }
    function 
    doAddEdit($id,$description) {
        if (
    intval($id) > 0) {
            
    $query sprintf("UPDATE categories SET CName = '%s' WHERE CID = '%s'",$description,$id);
            
    $result mysql_query($query) or die(mysql_error());
            
    $msg "Record Successfully Updated.";
        }
        else {
            
    $existing checkRecord($description);
            if (!
    $existing) {
                
    $query sprintf("INSERT INTO categories (CName) VALUES ('%s')",$description);
                
    $result mysql_query($query) or die(mysql_error());
                
    $msg "Record Successfully Added.";
            }
            elseif (
    $existing) {
                
    $msg "Record Already Exists.";
            }
        }
        return 
    $msg;
    }
    function 
    doDelete($id) {
        
    $query sprintf("DELETE FROM categories WHERE CID = '%s'",$id);
        
    $result mysql_query($query) or die(mysql_error());
        
    $msg "Record Successfully Deleted.";
        return 
    $msg;
    }
    sajax_init();
    sajax_export("doAddEdit");
    sajax_export("doDelete");
    sajax_handle_client_request();
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <link href="styles.css" rel="stylesheet" type="text/css">
    <head>
    <script language="javascript" type="application/javascript">
    <?php sajax_show_javascript(); ?>
    </script>
    <script language="javascript" type="text/javascript" src="prototype.js"></script>
    <script language="javascript" type="text/javascript">
    window.onload = function() {
        objCID = document.getElementById("CID");
        objDescription = document.getElementById("CName");
        objSubmit = document.getElementById("Submit");
        
        objDescription.focus();
        objDescription.select();

        objCID.value = 0;
        objDescription.value = "";
        objSubmit.value = "Save New";
    }
    function Callback(val) {
        alert(val);
        //loadPage();
        window.location = "categories.php";
    }
    function doAddEdit() {
        objID = document.getElementById("CID");
        objDescription = document.getElementById("CName");
        
        [COLOR="Red"]x_doAddEdit(objID.value,objDescription.value,Callback); ----> this is the error [/COLOR]
        return false;
    }
    function doEdit(id,description) {
        objID = document.getElementById("CID");
        objDescription = document.getElementById("CName");
        objSubmit = document.getElementById("Submit");
        
        objID.value = id;
        objDescription.value = description;
        objSubmit.value = "Update...";
    }
    function doDelete(id) {
        if (window.confirm("Proceed with delete?") == true) {
            [COLOR="Red"]x_doDelete(id,Callback);  ----> so as this is as well[/COLOR]
        }
    }
    function MM_openBrWindow(theURL,winName,features) { //v2.0
      window.open(theURL,winName,features);
    }
    </script>
    </head>

    <body>
    <div align="center"><?php require_once("header.php"); ?></div>
    <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1" onsubmit="return doAddEdit()">
    <table width="770" border="0"  cellpadding="0" cellspacing="0" align="center" class="table">
      <tr>
        <td align="center">
        <table width="750" border="0" cellpadding="3" cellspacing="3" align="center">
        <tr class="row1">
          <td width="697" height="25" class="heading" align="left">ADD CATEGORY</td>
        </tr>
          </table>
        <table width="749" height="158" border="0" align="center" cellpadding="2" cellspacing="2" class="dataTable">
          <tr>
            <td class="row1"><strong>Category Name:</strong></td>
            <td colspan="4" class="row2"><input name="CName" type="text" id="CName" size="45" /></td>
          </tr>
          <tr>
            <td><input name="CID" type="hidden" id="CID" value="0" /></td>
            <td colspan="4"><input name="Submit" type="submit" class="button" id="Submit" value="Save New" /></td>
          </tr>
          <tr class="row1">
            <th width="102" align="left">Category  ID</th>
            <th width="532" align="left">Category Name</th>
            <th colspan="3" align="left"><div align="center">Option</div></th>
          </tr>
          <?php
            $query 
    "";
            
    $query "SELECT * FROM categories ORDER BY CID ASC";
            
    $pager = new Pager();
            
    $pager->setQuery($query);
            
    $result mysql_query($pager->getLimitQuery()) or die(mysql_error());
            
    $color 0;
            if (
    mysql_num_rows($result)) {
                while (
    $row mysql_fetch_assoc($result)) {
            if (
    $color == 1) {
                
    $color 0;
            
    ?>
            <tr valign="top" class="row3">
            <?php 
            else if (
    $color == 0) {
                
    $color 1;
            
    ?>
            <tr valign="top" class="row2">
            <?php ?>
            <td valign="top"><?php echo $row['CID']; ?></td>
            <td valign="top">
                <table width="200" border="0">
                  <tr>
                    <td align="left"><?php echo $row['CName']; ?></td>
                  </tr>
                </table>
            </td>
            <td width="27" align="center" valign="top"></td>
            <td width="33" align="center" valign="top"><a href="javascript:doEdit('<?php echo $row['CID']; ?>','<?php echo $row['CName']; ?>')"><img src="images/icon_edit.gif" title="Edit" alt="Edit" width="17" height="16" border="0" /></a></td>
            <td width="23" align="center" valign="top"><a href="javascript:doDelete('<?php echo $row['CID']; ?>')"><img src="images/icon_delete.gif" title="Delete" alt="Delete" width="15" height="16" border="0" /></a></td>
          </tr>
          <?php
                
    }
                
    ?>
            <tr>
              <td colspan="5" class="row1">
                <div class="normaltextwhite"><?php echo $pager->getPager(); ?></div></td>
            </tr>
            <?php
            
    }
            else {
                
    ?>
          <tr class="row1">
            <td colspan="5"><strong>No records found...</strong></td>
          </tr>
          <?php
            
    }
            
    ?>
        </table>
        </td>
      </tr>
    </table>
    </form>
    <div align="center"><?php require_once("footer.html"); ?></div>
    </body>
    </html>
    Please help me. Thanks.
    Last edited by Alan; 04 Jul 2009 at 03:47 AM. Reason: Added PHP bb code tags

Similar Threads

  1. PHP Runtime for XP Pro
    By jword in forum General Questions
    Replies: 1
    Last Post: 30 Mar 2008, 07:17 PM

Posting Permissions

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