...

View Full Version : Delete code did not work



newphpcoder
05-03-2011, 11:45 AM
Good day!
I have a javascript code for delete but it did not work.
here is my test1.php 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


<!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

AndrewGSW
05-03-2011, 12:09 PM
JavaScript is case-sensitive.

<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum