SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: run time error

  1. #1
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Atlanta
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    run time error

    I'm working on a project. On that I need to delete and before I delete I need a confirm box. I have written this jave script. And when I call it in body, I have error 'run time error'. Then it shows the 'javascript:confirm_box(jfkw9090)' not defined.

    function confirm_box(class_id)
    {
    var agree = confirm("Are you sure you want to delete this class?");
    if (agree)
    {
    document.location ="<? echo $PHP_SELF; ?> &delete=yes";
    }
    else
    {
    alert("Class is not deleted");
    }
    }
    </head>
    <body>
    if (isset ($login))
    { //echo "These are all the courses belong to this ID";
    if ($delete == "yes")
    {
    delete_class($class_id);
    }

    <a href ="javascript:confirm_box?(<?echo $row["class_id"];?>)"> I have that error on this line
    Aneal

  2. #2
    SitePoint Columnist Skunk's Avatar
    Join Date
    Jan 2001
    Location
    Lawrence, Kansas
    Posts
    2,066
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It looks like you are getting mixed up with where to put the start and end PHP tags <?php and ?> - is that the full script? You seem to have forgotten to put a <?php tag before the PHP instructions after the <body> HTML tag.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    Atlanta
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I didn't write the whole script here, I've just copy the code which is giving me an error.
    Actual file is this:

    <html>
    <head>
    <script language = "javascript">
    function confirm_box(class_id)
    {
    id = eval(class_id);
    var agree = confirm("Are you sure you want to delete this class?");
    if (agree)
    {
    document.location ="<?echo $PHP_SELF; ?>?email_id =<?echo $email_id; ?> &delete=yes&class_id="+id;
    }
    else
    {
    alert("Class is not deleted");
    }
    }
    </script>
    </head>
    <?include ("database.php3");
    include ("del_class.php3");
    $link = connect_dbs($hostname, $username, $password, $dbname);
    ?>
    <body>
    <form name = "email_id" method = "get" action="<? $PHP_SELF ?>">
    <table> <tr> <td><input type=text name=email_id</td>
    </tr>
    <tr>
    <td><input type=submit value = "Login" name ="login"></td>
    </tr>
    </table>
    </center>
    </form>
    <?
    if (isset ($login))
    {
    if ($delete == "yes")
    {
    delClass($class_id);
    }

    if ($email_id)
    {
    $sql = ("select * from class a, fac b where a.faculty_id ='$email_id' and a.faculty_id = b.faculty_id");
    $result = mysql_query ($sql);
    $numrows = mysql_num_rows($result);
    $row = mysql_fetch_array($result);

    ?>
    <a href="edit_faculty.php3?faculty_id=<?echo $row["faculty_id"];?>">
    <img src="edit1.gif" width="32" hight="45" border="0" name="image4"></a></td>
    </tr></table>

    mysql_free_result($result);
    $result = mysql_query ($sql);
    while ($row = mysql_fetch_array($result))
    {
    ?>
    <table width=550>
    <tr>
    <td valign=top width=90>
    <a href ="edit_class.php3?class_id=<?echo $row["class_id"];?>">Edit</a></td>

    <td valign=top width=120>
    <a href ="javascript:confirm_box(<?echo $row["class_id"];?>)">Delete</a></td>

    </tr></table>
    <?
    }
    mysql_free_result($result);
    ?>
    </tr></table>
    <?
    }
    mysql_close($link);
    }
    exit;
    ?>
    </body>
    </html>
    Aneal


Bookmarks

Posting Permissions

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