ayok Posted September 27, 2007 Author Share Posted September 27, 2007 I even cannot target yahoo.com Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 27, 2007 Share Posted September 27, 2007 Do you have a link to the page? Quote Link to comment Share on other sites More sharing options...
emehrkay Posted September 27, 2007 Share Posted September 27, 2007 has this been suggested: var msg = confirm('message here'); if(msg){ //do something } //no need for an else Quote Link to comment Share on other sites More sharing options...
ayok Posted September 28, 2007 Author Share Posted September 28, 2007 Hi emehrkay, It still doesn't work thanks, ayok Quote Link to comment Share on other sites More sharing options...
ayok Posted September 28, 2007 Author Share Posted September 28, 2007 Do you have a link to the page? Hi roopurt, the link It uses the last code you gave me. I use opera, after click on "ok", it doesn't go to anypage. If you use IE, then it goes to blank url. thanks, ayok Quote Link to comment Share on other sites More sharing options...
emehrkay Posted September 28, 2007 Share Posted September 28, 2007 try window.location Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 28, 2007 Share Posted September 28, 2007 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> Quote Link to comment Share on other sites More sharing options...
roopurt18 Posted September 28, 2007 Share Posted September 28, 2007 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> Quote Link to comment Share on other sites More sharing options...
nogray Posted September 28, 2007 Share Posted September 28, 2007 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>"; ?> Quote Link to comment Share on other sites More sharing options...
ayok Posted September 29, 2007 Author Share Posted September 29, 2007 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.