dadamssg Posted July 24, 2009 Share Posted July 24, 2009 I'm not really familiar with javascript but i've come up with a confirm box that asks if they really want to delete a message but i don't know how to incorporate it into a while loop. I'm listing out all subjects of messages sent to a person. And then i have an X next to each one for them to click and when they do i want the confirm box to pop up. I just don't know how to incorporate this in the head <script type="text/javascript"> function show_confirm() { var r=confirm("Really delete?"); if (r==true) { window.location = "deletemessage.php?ms=<?php echo $row['messageid']; ?>" } else { } } </script> with this while loop in the body while ($row = mysqli_fetch_assoc($result)) { echo "<div id='mwrap'><div id='mwidth'><div id='floatl'>{$status}</div><div id='floatr'><a href= profile.php?uu={$row['sentby']} class='profile'>{$row['sentby']}</a><br><div class='user'>{$time}</div></div></div>"; echo "<div id='twidth'><a href = showmessage.php?ms={$row['messageid']} class='subject'>{$id}</a></div>"; echo "<div id='delete'><a href ='#' onclick='show_confirm()' class='delete'>X</a></div></div>"; } echo "<br>"; the problem right now is that the confirm box only pulls up the number for the first message....so all of the X's link to the same exact alert box Quote Link to comment Share on other sites More sharing options...
xtopolis Posted July 24, 2009 Share Posted July 24, 2009 Pass the id in the while loop, receive it in the javascript function. <script type="text/javascript"> function show_confirm(mid) { var r=confirm("Really delete?"); if (r==true){ window.location = "deletemessage.php?ms=" + mid; } } </script> (this above could be made more nifty with ajax) ... echo '<div id="delete"><a href ="#" onclick="show_confirm(\'" . $row['messageid'] . "\')" class="delete">X</a></div></div>'; Should be something similar to that. not tested. Quote Link to comment Share on other sites More sharing options...
dadamssg Posted July 29, 2009 Author Share Posted July 29, 2009 yeah i would love to use ajax...im just ajax illiterate... 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.