Jump to content

[SOLVED] Confirm Box?


ayok

Recommended Posts

It doesn't look to me like you're using the code I gave you.

 

Your function

function disp_confirm(){
    var name=confirm("Benar2 mau dihapus?")
    if (name==true){
        window.location.href = "delete.php?id=1";
    }
    else{
	return true;
	}
}

 

The one I gave you

function disp_confirm(){
    var msg = "Do you really want to delete this?";
    if (confirm(msg)){
        window.location.href = "delete.php?id=<?php echo $datakategori['id_cat'];?>";
    }
    return false;
}

 

Your links

<a href='' onclick='disp_confirm()'>delete</a>

 

The links I gave you

<a href='' onclick='return disp_confirm();'>delete</a>

Link to comment
Share on other sites

In the interest of getting this solved:

 

<?php
$show = mysql_query("SELECT service.*,category.name FROM service LEFT JOIN category on service.category=category.id_cat WHERE category='$id'") or die(mysql_error());
echo "<table border=0><tr bgcolor='#D0DCE0'><th>Service</th><th>Description</th><th>Duration (minutes)</th><th>Prices</th></tr>";


    while (($data = mysql_fetch_array($tampil)) && (mysql_num_rows($tampil) > 0))
    {
        echo "<tr>";
        echo "<td bgcolor='#D47FFF'>$data[name_serv]</td>";
        echo "<td bgcolor='#FF55FF'>$data[desc_serv]</td>";
        echo "<td bgcolor='#D47FFF'>$data[minutes]</td>";
        echo "<td bgcolor='#FF55FF'>$data[price]</td>";
        echo "<td><a href='' onclick='return disp_confirm()'>delete</a><br><a href=edit_service.php?id=$data[id_serv]>edit</a></td></tr>";
    }
    echo "</table>";
}?>

<script type="text/javascript">
function disp_confirm(){
    var msg = "Do you really want to delete this?";
    if (confirm(msg)){
        window.location.href = "delete.php?id=<?php echo $datakategori['id_cat']; ?>";
    }
    return false;
}
</script>

Link to comment
Share on other sites

You have one major problem

 

You have one function to delete more than one record, but it only have one ID variable.

 

Your delet link should be in the a tag (not in the function). Here is the easiest way to create a confirm for deletion

 

<?PHP
echo "<a href=\"delete.php?id=".$datakategori['id_cat']."\" onclick=\"return confirm('are you sure you want to delete?');\">Delete</a>";
?>

Link to comment
Share on other sites

In the interest of getting this solved:

 

<?php
$show = mysql_query("SELECT service.*,category.name FROM service LEFT JOIN category on service.category=category.id_cat WHERE category='$id'") or die(mysql_error());
echo "<table border=0><tr bgcolor='#D0DCE0'><th>Service</th><th>Description</th><th>Duration (minutes)</th><th>Prices</th></tr>";


    while (($data = mysql_fetch_array($tampil)) && (mysql_num_rows($tampil) > 0))
    {
        echo "<tr>";
        echo "<td bgcolor='#D47FFF'>$data[name_serv]</td>";
        echo "<td bgcolor='#FF55FF'>$data[desc_serv]</td>";
        echo "<td bgcolor='#D47FFF'>$data[minutes]</td>";
        echo "<td bgcolor='#FF55FF'>$data[price]</td>";
        echo "<td><a href='' onclick='return disp_confirm()'>delete</a><br><a href=edit_service.php?id=$data[id_serv]>edit</a></td></tr>";
    }
    echo "</table>";
}?>

<script type="text/javascript">
function disp_confirm(){
    var msg = "Do you really want to delete this?";
    if (confirm(msg)){
        window.location.href = "delete.php?id=<?php echo $datakategori['id_cat']; ?>";
    }
    return false;
}
</script>

 

Hi roopurt,

 

Thank you for being so patient to help me to solve my problem ;). This is what I found.

the links should be "delete.php?id=<?php echo $data['id_serv']; ?>"; I want to delete the service item, not the category. I don't know why I used that $datakategori variable. Anyway, I've changed the links to "$data['id_serve]".

 

However, it keeps getting the links of $datakategori variable. Its probably getting confused because the link is outside the php code. So, nogray is right. Thanks for your code. It's working now.

 

Thank you,

ayok

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.