dadamssg Posted August 9, 2009 Share Posted August 9, 2009 I have a forum and i want to give the users the ability to delete their posts if they have a typo or whatever. But i want to ask them if they are sure. How would i go about writing some javascript that would default say "Delete Your Post?" and then onclick change to "<a href='deleteresponse.php?id=23'>Yes</a> or No. And if they click No it will change back to "Delete Your Post?". i think this is fairly simple but just don't know how to do it Link to comment https://forums.phpfreaks.com/topic/169479-help-with-js-thing/ Share on other sites More sharing options...
dadamssg Posted August 9, 2009 Author Share Posted August 9, 2009 i think i have a little bit of it figure out below <html> <body> <p><b>Delete Post</b></p> <script type="text/javascript"> window.onclick=function(){ document.getElementsByTagName("p")[0].innerHTML="<b><a href='#'>Delete</a> || Cancel</b>" } </script> </body> </html> but how would i write that part that when cancel is pushed it goes back to default Link to comment https://forums.phpfreaks.com/topic/169479-help-with-js-thing/#findComment-894199 Share on other sites More sharing options...
dadamssg Posted August 9, 2009 Author Share Posted August 9, 2009 well i've got this now, but i can't get the second script to change it back to Delete Post <html> <body> <span><b>Delete Post</b></span> <script type="text/javascript"> document.getElementsByTagName("span")[0].onclick=function(){ document.getElementsByTagName("span")[0].innerHTML="<b><a href='#'>Delete</a> || <a href='#' id='del'>Cancel</a></b>" } </script> <script type="text/javascript"> document.getElementById('del').onclick=function(){ document.getElementsByTagName("span")[0].innerHTML="<b>Delete Post</b>" } </script> </body> </html> Link to comment https://forums.phpfreaks.com/topic/169479-help-with-js-thing/#findComment-894255 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.