Jump to content

help with js thing


dadamssg

Recommended Posts

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
Share on other sites

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
Share on other sites

well i've got this now, but i can't get the second script to change it back to Delete Post  :facewall:

 

<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
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.