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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2010
    Posts
    712
    Thanks
    165
    Thanked 0 Times in 0 Posts

    Delete code did not work

    Good day!
    I have a javascript code for delete but it did not work.
    here is my test1.php code
    Code:
    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Machine 1 Problem</title>
    <script type="text/JavaScript">
     
    FUNCTION confirmDelete(){
    VAR agree=CONFIRM("Are you sure you want to delete this file?");
    IF (agree)
         RETURN TRUE ;
    ELSE
         RETURN FALSE ;
    }
    </script>
    </head>
    
    <body>
    <form method="post" action="machine_1.php" name="machine1">
    <?php
    $db_host = 'localhost';
    $db_user = 'root';
    $db_name = 'db_machine1';
    
    $query = mysql_connect("$db_host", "$db_user")or die (mysql_error());
    $db = mysql_select_db("$db_name")or die (mysql_error());
    
    $query = "SELECT * FROM tbl_machine1 ORDER BY Emp_ID ASC";
    $result = mysql_query($query) or die(mysql_error());
    
    echo "<table border='1'><tr>";
    for($i = 0; $i < mysql_num_fields($result); $i++){
    	echo "<th>".mysql_field_name($result, $i)."</th>";
    	//echo "<th><a>.mysql_field_name($result, $i).""</a></th>";
    }
    echo "<th>Options</th>";
    echo "</tr>";
    while($row = mysql_fetch_array($result)){
    	echo "<tr>";
    	for($i = 0; $i < mysql_num_fields($result); $i++){
    		echo "<td>". $row[$i] ."</td>";
    	}
    	echo "<td><a href = 'edit.php'>Edit</a> <a href = 'delete.php' onClick='confirmDelete()';>Delete</a></td>";
    	echo "</tr>";
    }
    
    echo "</table>";
    echo "<input type = 'button' name= 'add' value='ADD'>";
    
    ?>
    </form>
    </body>
    </html>
    and here is my delete.php code
    Code:
    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <body>
    <form method="post" action="test1.php" name="delete">
    <?php
    echo "Delete";
    ?>
    </form>
    </body>
    </html>
    I don't know whats wrong why the pop message did not appear.

    thank you

  • #2
    Senior Coder
    Join Date
    Apr 2011
    Location
    London, England
    Posts
    2,120
    Thanks
    15
    Thanked 354 Times in 353 Posts
    JavaScript is case-sensitive.
    Code:
    <script type="text/JavaScript"> // not (actually) incorrect but
     
    FUNCTION confirmDelete(){
    VAR agree=CONFIRM("Are you sure you want to delete this file?");
    IF (agree)
         RETURN TRUE ;
    ELSE
         RETURN FALSE ;
    }
    </script>
    "I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
    Validate your HTML and CSS


  •  

    Posting Permissions

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