Enjoy an ad free experience by logging in. Not a member yet?
Register .
02-01-2012, 02:52 AM
PM User |
#1
New Coder
Join Date: Jan 2012
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Javascript : Confirm Delete
Hi I really really really need your help since I have no idea about this.
How can I insert the Javascript Confirmation Alert into the del.php file?
I have this del.php file
PHP Code:
<?php
require ( "include/config.php" );
$id = $_REQUEST [ 'id' ];
$strSQL = "DELETE FROM change WHERE id = '" . $id . "' " ;
$objQuery = odbc_exec ( $conn , $strSQL );
if( $objQuery )
{
echo "<script language='Javascript'>alert('Deleted.');
window.location=\"" . "index.php?action=syif\"</script>" ;
}
else
{
echo "Error Delete [" . $strSQL . "]" ;
}
odbc_close ( $conn );
?>
This is the confirmation javascript
Code:
<html>
<head>
<script type="text/javascript">
function show_confirm()
{
var r=confirm("Delete?");
if (r==true)
{
alert("Deleted!");
}
else
{
alert("Cancelled!");
}
}
</script>
</head>
<body>
<input type="button" onclick="show_confirm()" value="Show confirm box" />
</body>
</html>
02-01-2012, 07:01 AM
PM User |
#2
Senior Coder
Join Date: Dec 2010
Posts: 2,261
Thanks: 10
Thanked 533 Times in 527 Posts
This is a fuzzy question ... what does del.php have to do with the confirmation javascript? Please describe your problem, ideally step by step.
02-01-2012, 08:52 AM
PM User |
#3
New Coder
Join Date: Jan 2012
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
This is a fuzzy question ... what does del.php have to do with the confirmation javascript? Please describe your problem, ideally step by step.
Okay i have this del.php file. Then i wanted to add confirmation alert when deleting the data.
So, how can i add the confirmation alert into the del.php file?
I hope you understand my problem
02-01-2012, 09:58 AM
PM User |
#4
Senior Coder
Join Date: Dec 2010
Posts: 2,261
Thanks: 10
Thanked 533 Times in 527 Posts
What do you do with del.php? Where and how do you call it (page refresh, Ajax)? What do you do with the output of the script? Your information is not sufficient to answer those questions.
02-01-2012, 10:15 AM
PM User |
#5
New Coder
Join Date: Jan 2012
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
What do you do with del.php? Where and how do you call it (page refresh, Ajax)? What do you do with the output of the script? Your information is not sufficient to answer those questions.
Oh yeah i forgot. I have this changeshift.php file. The del.php file will be called here. I've bold the coding where it is called
PHP Code:
$syif = $_REQUEST['idstaff_info'];
$sql ="SELECT DISTINCT staff_info.*, staff_shift.ss_name
FROM staff_info
INNER JOIN staff_shift
ON staff_shift.idstaff_shift = staff_info.idstaff_shift
WHERE staff_info.idstaff_info = '".$syif."' ";
$objExec = odbc_exec($conn, $sql);
$objResult = odbc_fetch_array($objExec);
if(!$objResult)
{
echo "Not found idstaff_info=".$_REQUEST["idstaff_info"];
}
else {
?>
<script type="text/ecmascript">"var time_variable; function getXMLObject()"</script>
<script type="text/javascript" src="calendar/calendar.js"></script>
<link rel="stylesheet" type="text/css" href="calendar/calendar.css" title="default" />
<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 name="lina" method="post" action="tukarscript.php">
<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center">Penukaran Syif</td>
</tr>
<tr>
<td width="649"><p> </p>
<table width="593" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="right">Nama :</div></td>
<td> </td>
<td><?php echo $objResult [ 'si_name' ]; ?> </td>
</tr>
<tr>
<td><div align="right">Id Pekerja:</div></td>
<td> </td>
<td><?php echo $objResult [ 'si_emp_num' ]; ?> </td>
</tr>
<tr>
<td width="213"><div align="right">Syif Sekarang:</div></td>
<td width="10"> </td>
<td width="370"><?php echo $objResult [ 'ss_name' ]; ?>
<input type="hidden" name="syif_lama" value="<?php echo $objResult [ 'idstaff_shift' ]; ?> " />
<input type="hidden" name="idstaff" value="<?php echo $objResult [ "idstaff_info" ] ?> " /></td>
</tr>
<tr>
<td><div align="right">Tukar Kepada Syif:</div></td>
<td> </td>
<td>
<label>
<select name="idstaff_shift" size="1" id="idstaff_shift">
<option selected="selected" value="<?php echo $idstaff_shift ; ?><?php echo $idstaff_shift ; ?> "></option>
<?php
$sql1 = "SELECT DISTINCT idstaff_shift, ss_name FROM staff_shift " ;
$query = odbc_exec ( $conn , $sql1 );
while ( odbc_fetch_row ( $query )) {
$idstaff_shift = odbc_result ( $query , "idstaff_shift" );
$ss_name = odbc_result ( $query , "ss_name" );
printf ( "<OPTION value=\"$idstaff_shift\">$ss_name</OPTION>" );
}
odbc_free_result ( $query );
?>
</select></label></td>
</tr>
<tr>
<td width="213"><div align="right">Pilih Tarikh:</div></td>
<td width="10"> </td>
<td><input type="text" name="dt_frm" value="<?php echo $dt_frm ; ?> " size="10" />
<a href="#" onClick="displayDatePicker('dt_frm', false, 'dmy', '/');"><img src="calendar/calendar.jpg" border="0"/></a> Hingga
<input type="text" name="dt_to" value="<?php echo $dt_to ; ?> " size="10" />
<a href="#" onClick="displayDatePicker('dt_to', false, 'dmy', '/');"><img src="calendar/calendar.jpg" border="0"/></a></td>
</tr>
<tr>
<td colspan="2"> </td>
<td><input type="submit" name="submit" value="TERUSKAN" /></td>
</tr>
</table>
<p> </p></td>
</tr>
</table>
<p>
<?php
odbc_close ( $conn );
}
$SQLList = " select distinct syifTukar.*, staff_shift.ss_name
from syifTukar
inner join staff_shift
on syifTukar.idsyif_baru=staff_shift.idstaff_shift
where syifTukar.idstaff_info='" . $objResult [ 'idstaff_info' ]. "' order by syifTukar.tarikh_mula asc " ;
$RSTList = odbc_exec ( $conn , $SQLList );
#$totalRows = odbc_num_rows( $RSTList );
?>
<p> </p>
<table width="522" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#EEEEEE">
<tr>
<td colspan="5"><div align="center">SEJARAH SYIF</div></td>
</tr>
<tr>
<td width="31" rowspan="2"><div align="center">NO</div></td>
<td colspan="2" align="center">TEMPOH SYIF</td>
<td width="86" rowspan="2"><div align="center">SYIF</div></td>
<td width="83" rowspan="2"><div align="center">TINDAKAN</div></td>
</tr>
<tr>
<td width="150"><div align="center">TARIKH MULA</div></td>
<td width="160"><div align="center">TARIKH AKHIR</div></td>
</tr>
<?php
$int = 1 ;
while ( odbc_fetch_row ( $RSTList ) )
{
$tarikh_mula = odbc_result ( $RSTList , "tarikh_mula" );
$tarikh_akhir = odbc_result ( $RSTList , "tarikh_akhir" );
$idsyif_baru = odbc_result ( $RSTList , "idsyif_baru" );
$id = odbc_result ( $RSTList , "id" );
$syif_nama = odbc_result ( $RSTList , "ss_name" );
$trkh_disp_start = "$tarikh_mula" ;
$dd_date = substr ( $trkh_disp_start , 8 , 2 );
$mm_date = substr ( $trkh_disp_start , 5 , 2 );
$yy_date = substr ( $trkh_disp_start , 0 , 4 );
$trkh_start = "{$dd_date}-{$mm_date}-{$yy_date}" ;
$trkh_start_date = "{$trkh_start}" ;
####################################################################
$trkh_disp_end = "$tarikh_akhir" ;
$dd_date = substr ( $trkh_disp_end , 8 , 2 );
$mm_date = substr ( $trkh_disp_end , 5 , 2 );
$yy_date = substr ( $trkh_disp_end , 0 , 4 );
$trkh_end = "{$dd_date}-{$mm_date}-{$yy_date}" ;
$trkh_end_date = "{$trkh_end}" ;
?>
[B][SIZE="3"]<tr>
<td><div align="center"><?php echo $int ++; ?> <input type="hidden" value="<?php echo $id ; ?> " name="idbaru" /></div></td>
<td><div align="center"><?php echo $trkh_start_date ; ?> </div></td>
<td><div align="center"><?php echo $trkh_end_date ; ?> </div></td>
<td><div align="center"><?php echo $syif_nama ; ?> </div></td>
<td><div align="center"><a href="index.php?action=del&id=<?php echo $id ; ?> ">Padam</a></div></td>[/SIZE][/B]
</tr><?php } ?>
</table>
</p>
</form>
<p> </p>
<p> </p>
</body>
</html>
02-01-2012, 10:17 AM
PM User |
#6
New Coder
Join Date: Jan 2012
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Well i hope you understand my question and coding. Thanks
02-01-2012, 11:06 AM
PM User |
#7
Senior Coder
Join Date: Dec 2010
Posts: 2,261
Thanks: 10
Thanked 533 Times in 527 Posts
I'm sorry but the is NO call to del.php in your code
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 01:37 PM .
Advertisement
Log in to turn off these ads.